Opened 16 years ago

Closed 16 years ago

Last modified 12 years ago

#8221 closed (fixed)

NoReverseMatch should not swallow ImportError/AttributeError

Reported by: eibaan Owned by: nobody
Component: Core (Other) Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In django.core.urlresolver.reverse around line 200, NoReverseMatch is raised without further details. Please provide more details to help debugging. In case of import or attribute errors, please provide the original exception and do not swallow it.

Attachments (4)

improved_exceptions_for_reverse.diff (2.0 KB ) - added by mrts 16 years ago.
improved_exceptions_for_reverse2.diff (1.8 KB ) - added by mrts 16 years ago.
Reverse minor needless whitespace change in previous patch
improved_exceptions_for_reverse_with-args.diff (2.1 KB ) - added by mrts 16 years ago.
Make 'Reverse for foo not found' more useful by showing the arguments as well. This really helps to fix problems in real life.
improved_exceptions_for_reverse_with-args_updated-AUTHORS.diff (2.6 KB ) - added by mrts 16 years ago.
Adding myself to AUTHORS

Download all attachments as: .zip

Change History (14)

comment:1 by eibaan, 16 years ago

#7821 has the same intention, I assume.

comment:2 by Julien Phalip, 16 years ago

Resolution: invalid
Status: newclosed

This should have been fixed in [8272]. Try with a more recent version of trunk.
If an exception is raised at that point, it's because the given view name could not be matched against the registered URLs.

Reopen this ticket if you estimate that the information given in the exception message -- basically, the unmatched view name -- is still not enough for debugging.

comment:3 by eibaan, 16 years ago

Resolution: invalid
Status: closedreopened

[8272] fixed two occurences of NoReverseMatch near line 291. Near line 200, there are two more occurences. Furthermore, it would be helpful to get access to the root cause (attribute or import error). I might be wrong, but "not a callable" is just a guess. For example, it could also be a syntax error in a Python file or a missing file that causes the import error.

by mrts, 16 years ago

Reverse minor needless whitespace change in previous patch

comment:4 by mrts, 16 years ago

Has patch: set
milestone: 1.0
Triage Stage: UnreviewedAccepted

eibaan is right, I just scratched the place where it itched when I submitted the patch that was merged in r8272. Should have looked around.

comment:5 by James Bennett, 16 years ago

Resolution: duplicate
Status: reopenedclosed

Looks like a dupe of #7524.

comment:6 by mrts, 16 years ago

Resolution: duplicate
Status: closedreopened

ubernostrum, this is a different issue than what's reported at #7524. Please look at the patch.

by mrts, 16 years ago

Make 'Reverse for foo not found' more useful by showing the arguments as well. This really helps to fix problems in real life.

comment:7 by mrts, 16 years ago

Justification for change in last patch:

in one of my projects, some articles had somehow invalid slugs (with spaces, I actually wonder how this is possible -- SlugField shouldn't allow saving these), so, of course I got 'Reverse for foo not found' for the article view. It took me a while to find out what's wrong. With this patch, I could instantly spot the problem.

by mrts, 16 years ago

Adding myself to AUTHORS

comment:8 by mrts, 16 years ago

Invalid slugs came from #8040 (fixed as late as in r8477, which means more people can be hit by exactly the same problem).

comment:9 by Jacob, 16 years ago

Resolution: fixed
Status: reopenedclosed

(In [8672]) Fixed #8221: added some better NoReverseMatch error strings. Thanks, mrts.

comment:10 by Jacob, 12 years ago

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top