This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients mark.dickinson, thatiparthy
Date 2017-12-31.11:57:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1514721430.69.0.467229070634.issue32464@psf.upfronthosting.co.za>
In-reply-to
Content
Here's the documentation, which I think explains all this clearly: briefly, `return NotImplemented` and `raise NotImplementedError` are the normal usages. `raise NotImplemented` doesn't make sense, and shouldn't be used: it'll end up raising a `TypeError`, sine `NotImplemented` is neither a subclass nor an instance of BaseException.

NotImplemented: https://docs.python.org/3.7/library/constants.html#NotImplemented

NotImplementedError:
https://docs.python.org/3.7/library/exceptions.html#NotImplementedError

Almost all of the grep results you're seeing do follow the expected patterns (either `return NotImplemented` or `raise NotImplementedError`, but a quick grep does show some questionable uses of `raise NotImplemented` in the standard library:

    MacBook-Pro:cpython mdickinson$ grep -r . -e raise   --include=\*.py  | grep "\bNotImplemented\b"
    ./Lib/asyncio/transports.py:    The implementation here raises NotImplemented for every method
    ./Lib/idlelib/debugger_r.py:        raise NotImplemented("dict_keys not public or pickleable")
    ./Lib/ssl.py:        raise NotImplemented("Can't dup() %s instances" %

The other way around also turns up an odd-looking `return NotImplementedError` (along with a false positive):

    MacBook-Pro:cpython mdickinson$ grep -r . -e return   --include=\*.py  | grep "\bNotImplementedError\b"
    ./Lib/ctypes/test/test_simplesubclasses.py:            return NotImplementedError
    ./Lib/test/test_asyncio/test_transports.py:        self.assertRaises(NotImplementedError, transport.get_returncode)
History
Date User Action Args
2017-12-31 11:57:10mark.dickinsonsetrecipients: + mark.dickinson, thatiparthy
2017-12-31 11:57:10mark.dickinsonsetmessageid: <1514721430.69.0.467229070634.issue32464@psf.upfronthosting.co.za>
2017-12-31 11:57:10mark.dickinsonlinkissue32464 messages
2017-12-31 11:57:10mark.dickinsoncreate