Message363973
> How is -1 interpreted? Does it become a TypeError?
It is interpreted as error. It requires an exception be set. If you return -1 without setting an exception you will usually get a SystemError or crash. Oh, and this may happen during executing other code, so you will search a bug in wrong place.
You cannot change this without breaking the C and Python API in hard way.
> So my thinking is that when the interpreter gets the `NotImplemented` returned by either `if a` or by `if not a` that it would be converted to a `TypeError`
> and the `and` machinery sees it has a `NotImplemented` and raises a `TypeError`.
So you literally want NotImplemented raising a TypeError in boolean context except the "not" operator, and redefine `not a` from
False if a else True
to
NotImplemented if a is NotImplemented else False if a else True
You can do this, but this is a different issue, and I doubt that it will solve many problems. |
|
Date |
User |
Action |
Args |
2020-03-11 21:41:19 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gvanrossum, terry.reedy, steven.daprano, ethan.furman, josh.r, veky, xtreak |
2020-03-11 21:41:19 | serhiy.storchaka | set | messageid: <1583962879.52.0.702341932837.issue35712@roundup.psfhosted.org> |
2020-03-11 21:41:19 | serhiy.storchaka | link | issue35712 messages |
2020-03-11 21:41:19 | serhiy.storchaka | create | |
|