Skip to content

Catch NoReverseMatch instead of having a bare except#72

Open
kronion wants to merge 1 commit into
fangli:masterfrom
kronion:catch-noreverseerror
Open

Catch NoReverseMatch instead of having a bare except#72
kronion wants to merge 1 commit into
fangli:masterfrom
kronion:catch-noreverseerror

Conversation

@kronion

@kronion kronion commented Nov 11, 2018

Copy link
Copy Markdown

A bare except: is generally bad practice because it can lead to unexpected behavior, such as handling KeyboardInterrupt. It is cleaner to be specific about what error conditions this code can handle: failed url lookups, i.e. NoRevereMatch.

Also, Django changed the location of these imports in 1.10. While it was still possible to use the old locations until 2.0, a warning would be logged. The warning is avoided by changing the version this code checks for.

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.

1 participant