PythonCharmers/python-future

futurize `__bool__` not implemented for subclasses of dict

Open

#282 geöffnet am 5. Mai 2017

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (327 Forks)batch import
0.20bughelp wanted

Repository-Metriken

Stars
 (1.172 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

If a run futurize on python 2 code containing a subclass of the built in dict, e.g.

class A(dict):
    __nonzero__(self):
    return False

it is translated to

class A(dict):
    __bool__(self):
    return False

However, the __bool__ method is not called in python 2. Seems some other kind of trickery is needed.

For now I'm working around the issue by doing

class A(dict):
    __bool__(self):
    return False
    if sys.version_info[0] == 2:
        __nonzero__ = __bool__

Contributor Guide