Code

#20841 closed Cleanup/optimization (fixed)

NotImplementedErrors should provide exception messages

Reported by: joseph@… Owned by: TimClifford
Component: Core (Other) Version: master
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)

Attachments (0)

Change History (5)

comment:1 Changed 11 months ago by claudep

  • Component changed from Uncategorized to Core (Other)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 1.5 to master

comment:2 Changed 10 months ago by TimClifford

  • Owner changed from nobody to TimClifford
  • Status changed from new to assigned

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 Changed 10 months ago by TimClifford

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 10 months ago by TimClifford (previous) (diff)

comment:4 Changed 10 months ago by TimClifford

  • Has patch set

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

comment:5 Changed 10 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In b2b763448f726ee952743596e9a34fcb154bdb12:

Fixed #20841 -- Added messages to NotImplementedErrors

Thanks joseph at vertstudios.com for the suggestion.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.