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
Boxiang Sun
cython
Commits
8b6131af
Commit
8b6131af
authored
7 years ago
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Repair "__richcmp__" generation for special comparison methods with docstrings.
Closes #2019.
parent
dfd73ac6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+2
-2
tests/run/ext_auto_richcmp.py
tests/run/ext_auto_richcmp.py
+18
-0
No files found.
Cython/Compiler/ModuleNode.py
View file @
8b6131af
...
@@ -2962,8 +2962,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -2962,8 +2962,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
is_buffer
=
func
.
name
in
(
'__getbuffer__'
,
'__releasebuffer__'
)
is_buffer
=
func
.
name
in
(
'__getbuffer__'
,
'__releasebuffer__'
)
if
(
func
.
is_special
and
Options
.
docstrings
and
if
(
func
.
is_special
and
Options
.
docstrings
and
func
.
wrapperbase_cname
and
not
is_buffer
):
func
.
wrapperbase_cname
and
not
is_buffer
):
slot
=
TypeSlots
.
method_name_to_slot
[
func
.
name
]
slot
=
TypeSlots
.
method_name_to_slot
.
get
(
func
.
name
)
preprocessor_guard
=
slot
.
preprocessor_guard_code
()
preprocessor_guard
=
slot
.
preprocessor_guard_code
()
if
slot
else
None
if
preprocessor_guard
:
if
preprocessor_guard
:
code
.
putln
(
preprocessor_guard
)
code
.
putln
(
preprocessor_guard
)
code
.
putln
(
'#if CYTHON_COMPILING_IN_CPYTHON'
)
code
.
putln
(
'#if CYTHON_COMPILING_IN_CPYTHON'
)
...
...
This diff is collapsed.
Click to expand it.
tests/run/ext_auto_richcmp.py
View file @
8b6131af
...
@@ -78,8 +78,12 @@ class ClassEq(X):
...
@@ -78,8 +78,12 @@ class ClassEq(X):
... else: a >= b
... else: a >= b
Traceback (most recent call last):
Traceback (most recent call last):
TypeError...
TypeError...
>>> print(a.__eq__.__doc__)
EQ
"""
"""
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
"""EQ"""
assert
1
<=
self
.
x
<=
2
assert
1
<=
self
.
x
<=
2
assert
isinstance
(
self
,
ClassEq
),
type
(
self
)
assert
isinstance
(
self
,
ClassEq
),
type
(
self
)
if
isinstance
(
other
,
X
):
if
isinstance
(
other
,
X
):
...
@@ -141,8 +145,14 @@ class ClassEqNe(ClassEq):
...
@@ -141,8 +145,14 @@ class ClassEqNe(ClassEq):
... else: a >= b
... else: a >= b
Traceback (most recent call last):
Traceback (most recent call last):
TypeError...
TypeError...
#>>> print(a.__eq__.__doc__)
#EQ
>>> print(a.__ne__.__doc__)
NE
"""
"""
def
__ne__
(
self
,
other
):
def
__ne__
(
self
,
other
):
"""NE"""
assert
1
<=
self
.
x
<=
2
assert
1
<=
self
.
x
<=
2
assert
isinstance
(
self
,
ClassEqNe
),
type
(
self
)
assert
isinstance
(
self
,
ClassEqNe
),
type
(
self
)
if
isinstance
(
other
,
X
):
if
isinstance
(
other
,
X
):
...
@@ -240,8 +250,16 @@ class ClassEqNeGe(ClassEqNe):
...
@@ -240,8 +250,16 @@ class ClassEqNeGe(ClassEqNe):
... else: a >= 'x'
... else: a >= 'x'
Traceback (most recent call last):
Traceback (most recent call last):
TypeError...
TypeError...
#>>> print(a.__eq__.__doc__)
#EQ
#>>> print(a.__ne__.__doc__)
#NE
>>> print(a.__ge__.__doc__)
GE
"""
"""
def
__ge__
(
self
,
other
):
def
__ge__
(
self
,
other
):
"""GE"""
assert
1
<=
self
.
x
<=
2
assert
1
<=
self
.
x
<=
2
assert
isinstance
(
self
,
ClassEqNeGe
),
type
(
self
)
assert
isinstance
(
self
,
ClassEqNeGe
),
type
(
self
)
if
isinstance
(
other
,
X
):
if
isinstance
(
other
,
X
):
...
...
This diff is collapsed.
Click to expand it.
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