Skip to content

bpo-35429: Use raise NotImplementedError instead of NotImplemented#10999

Closed
rth wants to merge 3 commits intopython:masterfrom
rth:not-implemented-error
Closed

bpo-35429: Use raise NotImplementedError instead of NotImplemented#10999
rth wants to merge 3 commits intopython:masterfrom
rth:not-implemented-error

Conversation

@rth
Copy link
Copy Markdown
Contributor

@rth rth commented Dec 6, 2018

Closes https://bugs.python.org/issue35429

In two places in stdlib, raise NotImplemented was used instead of raise NotImplementedError. The former is not valid and produces,

>>> raise NotImplemented('message')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NotImplementedType' object is not callable

https://bugs.python.org/issue35429

@rhettinger
Copy link
Copy Markdown
Contributor

Please add tests to prevent regression.

self.assertIsInstance(remote, ssl.SSLSocket)

with self.assertRaises(NotImplementedError):
remote.dup()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is not the best place to put this check, but it's not obvious to construct the ssl.SSLSocket instance manually, and there is no other place in this test file where we are sure to have such instance.

@rth
Copy link
Copy Markdown
Contributor Author

rth commented Dec 6, 2018

Thanks @rhettinger, added non regression tests..

@serhiy-storchaka
Copy link
Copy Markdown
Member

This is a duplicate of #10934.

@terryjreedy terryjreedy removed their request for review December 7, 2018 06:34
@rth rth deleted the not-implemented-error branch December 7, 2018 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants