Commit 8b6131af authored by Stefan Behnel's avatar Stefan Behnel

Repair "__richcmp__" generation for special comparison methods with docstrings.

Closes #2019.
parent dfd73ac6
...@@ -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')
......
...@@ -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):
......
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