Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored code to avoid a deprecation warning in Python 2.7 #41

Merged
merged 2 commits into from
Apr 16, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Refactored code to avoid a deprecation warning in Python 2.7
  • Loading branch information
epicserve committed Apr 15, 2013
commit 5f59c06adaa4d6cf5d59dd53337e38fce499e545
8 changes: 6 additions & 2 deletions payments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,13 @@ def subscribe(request, form_class=PlanForm):
customer.subscribe(form.cleaned_data["plan"])
data["form"] = form_class()
data["location"] = reverse("payments_history")
except stripe.StripeError, e:
except stripe.StripeError as e:
raise
data["form"] = form
data["error"] = e.message
try:
data["error"] = e.args[0]
except IndexError:
data["error"] = "Unknown error"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of code is unreachable due to the 'raise' on line 148 as reported by Travis

************* Module payments.views
W0101:148,12:subscribe: Unreachable code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops. If I'm correct you don't need line 147. Does that seem right to you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes in order to render the form errors, if there are any.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so stripe.StripeError no longer as a message attribute?

else:
data["error"] = form.errors
data["form"] = form
Expand Down