PythonCharmers/python-future

__bool__ = __nonzero__ not detected

Open

#453 opened on May 2, 2019

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Python (327 forks)batch import
0.19bugfuturize scripthelp wanted

Repository metrics

Stars
 (1,172 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Code like:

class Foo(object):
    def __nonzero__(self):
        return True
    __bool__ = __nonzero__

results in

from builtins import object
class Foo(object):
    def __bool__(self):
        return True
    __bool__ = __nonzero__

and therefore raises in Python3:

  File "test.py", line 2, in <module>
    class Foo(object):
  File "test.py", line 5, in Foo
    __bool__ = __nonzero__
NameError: name '__nonzero__' is not defined


Contributor guide