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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
8b6131af
Commit
8b6131af
authored
Nov 24, 2017
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
Show 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'
)
...
...
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
):
...
...
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