Opened 11 years ago

Closed 11 years ago

#20841 closed Cleanup/optimization (fixed)

NotImplementedErrors should provide exception messages

Reported by: joseph@… Owned by: Tim Clifford
Component: Core (Other) Version: dev
Severity: Normal Keywords: NotImplementedError
Cc: joseph@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The Django source has many occurrences of NotImplementedErrors raised without a message. For example, if a dev creates a class inheriting from contrib.admin.SimpleListFilter and does not provide a lookups() method, all they see from the Debug template is "NotImplementedError at /path/to/file/ No exception supplied". This, in my opinion, makes seeking help difficult for those not comfortable enough to dig through the Django source. A simple message such as "instances of SimpleListFilter must provide a lookups() method" provides instant feedback and a non-ambiguous means to seeking help if needed.

In short, my request is to have all NotImplementedError exceptions raised accompanied by a message.

I realize this change would be boring to work on, so I am more than willing to read through the patch procedures and submit a patch myself if you all find this a worthy cause. (The nature of this request may even be simple enough to send through Github)

Change History (5)

comment:1 by Claude Paroz, 11 years ago

Component: UncategorizedCore (Other)
Triage Stage: UnreviewedAccepted
Version: 1.5master

comment:2 by Tim Clifford, 11 years ago

Owner: changed from nobody to Tim Clifford
Status: newassigned

Looks like gruntwork that requires a base level of code literacy, which is perfect to assign during a sprint.

I'm on it!

comment:3 by Tim Clifford, 11 years ago

Pull request submitted and awaiting review. 92 instances of "raise NotImplementedError" used to placehold base class methods for subclassing were given verbose may/must subclass explanations, and two instances of not-implemented features were written up as well (found in /utils/datetime.py line number 67 and /utils/regex_helper.py line number 95).

Last edited 11 years ago by Tim Clifford (previous) (diff)

comment:4 by Tim Clifford, 11 years ago

Has patch: set

Added a patch in the form of a Pull Request, visible here:
https://github.com/django/django/pull/1569

comment:5 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In b2b763448f726ee952743596e9a34fcb154bdb12:

Fixed #20841 -- Added messages to NotImplementedErrors

Thanks joseph at vertstudios.com for the suggestion.

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