Commit f31aac14 authored by Lisandro Dalcin's avatar Lisandro Dalcin

Py3: __cmp__ is gone, __bool__ instead of __nonzero__

parent 3b44dbd8
......@@ -11,7 +11,8 @@ import Symtab
class AutoTestDictTransform(ScopeTrackingTransform):
# Handles autotestdict directive
blacklist = ['__cinit__', '__dealloc__', '__richcmp__', '__nonzero__',
blacklist = ['__cinit__', '__dealloc__', '__richcmp__',
'__nonzero__', '__bool__',
'__len__', '__contains__']
def visit_ModuleNode(self, node):
......
This diff is collapsed.
......@@ -126,4 +126,20 @@ cdef class MyCdefClass:
False
"""
cdef class MyOtherCdefClass:
"""
Needs no hack
>>> True
True
"""
def __bool__(self):
"""
Should not be included, as it can't be looked up with getattr in Py 2
>>> True
False
"""
cdeffunc()
__doc__ = """
>>> not not BoolA(0)
False
>>> not not BoolA(1)
True
>>> not not BoolB(0)
False
>>> not not BoolB(1)
True
>>> not not BoolX(0)
False
>>> not not BoolX(1)
True
>>> not not BoolY(0)
False
>>> not not BoolY(1)
True
"""
cdef class BoolA:
cdef bint value
def __cinit__(self, bint value):
self.value = value
def __nonzero__(self):
return self.value
cdef class BoolB:
cdef bint value
def __cinit__(self, bint value):
self.value = value
def __bool__(self):
return self.value
cdef class BoolX(BoolA):
pass
cdef class BoolY(BoolB):
pass
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment