PythonCharmers/python-future

__bool__ = __nonzero__ not detected

Open

#453 建立於 2019年5月2日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)Python (327 fork)batch import
0.19bugfuturize scripthelp wanted

倉庫指標

Star
 (1,172 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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


貢獻者指南