[issue32464] raise NotImplemented vs return NotImplemented

2018-05-29 Thread Yury Selivanov


Yury Selivanov  added the comment:

Seems this issue isn't a bug and can be closed.

--
nosy: +yselivanov
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32464] raise NotImplemented vs return NotImplemented

2017-12-31 Thread Mark Dickinson

Mark Dickinson  added the comment:

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)

--
nosy: +mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32464] raise NotImplemented vs return NotImplemented

2017-12-31 Thread Srinivas Reddy T

New submission from Srinivas  Reddy T :

I ran these queries on cpython repo.

➜  cpython git:(master) ✗ grep -r . -e return  --include=\*.py  | grep 
NotImplemented | wc -l
196

➜  cpython git:(master) ✗ grep -r . -e raise   --include=\*.py  | grep 
NotImplemented | wc -l
295

I have always used raise NotImplemented or raise NotImplementedError. But when 
does it make sense to return NotImplemented?

--
messages: 309277
nosy: thatiparthy
priority: normal
severity: normal
status: open
title: raise NotImplemented vs return NotImplemented
type: resource usage
versions: Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com