Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:
> 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35712> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com