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

Fix UnboundLocalError when accessing amount #480

Merged
merged 2 commits into from
Jan 28, 2025

Conversation

pxwxnvermx
Copy link
Contributor

@pxwxnvermx pxwxnvermx commented Jan 27, 2025

Product Description

This fixes an error when the user tries to submit payments with non-integer amounts i.e INR 1000, USD 100.

Technical Summary

This error was due to the Unbound amount variable when the ValueError exception occurred for non-integer amounts.

Sentry Link

Labels & Review

  • The set of people pinged as reviewers is appropriate for the level of risk of the change

except ValueError:
invalid_rows.append((row, "amount must be an integer"))
payments[username] = amount
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the "correct" way to do this is put it in an else clause. We don't want to catch errors with that statement (although I am not sure that is possible here), but only want it to run if the the try succeeds, and else is the standard way to do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Added. 14828cf

@pxwxnvermx pxwxnvermx merged commit 33960cf into main Jan 28, 2025
5 checks passed
@pxwxnvermx pxwxnvermx deleted the pkv/fix-amount-unbound-error branch January 28, 2025 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants