Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
f31aac14
Commit
f31aac14
authored
Apr 28, 2010
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Py3: __cmp__ is gone, __bool__ instead of __nonzero__
parent
3b44dbd8
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
43 deletions
+113
-43
Cython/Compiler/AnalysedTreeTransforms.py
Cython/Compiler/AnalysedTreeTransforms.py
+2
-1
Cython/Compiler/TypeSlots.py
Cython/Compiler/TypeSlots.py
+52
-42
tests/run/autotestdict.pyx
tests/run/autotestdict.pyx
+16
-0
tests/run/type_slots_nonzero_bool.pyx
tests/run/type_slots_nonzero_bool.pyx
+43
-0
No files found.
Cython/Compiler/AnalysedTreeTransforms.py
View file @
f31aac14
...
...
@@ -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
):
...
...
Cython/Compiler/TypeSlots.py
View file @
f31aac14
This diff is collapsed.
Click to expand it.
tests/run/autotestdict.pyx
View file @
f31aac14
...
...
@@ -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
"""
cdef
func
()
tests/run/type_slots_nonzero_bool.pyx
0 → 100644
View file @
f31aac14
__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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment