diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2017-11-24 09:00:29 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2017-11-24 09:00:43 +0100 |
commit | 8b6131afbabbfef27980bd2fd7e3fee4f1fd8a5b (patch) | |
tree | 00514564ae90dde30b928c2c1d56e8a61b4e5151 | |
parent | dfd73ac65d3b55af85b4dcc1dda62a141efaad6c (diff) | |
download | cython-0.27.x.tar.gz |
Repair "__richcmp__" generation for special comparison methods with docstrings.0.27.x
Closes #2019.
-rw-r--r-- | Cython/Compiler/ModuleNode.py | 4 | ||||
-rw-r--r-- | tests/run/ext_auto_richcmp.py | 18 |
2 files changed, 20 insertions, 2 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index d6c322e2b..fb652171e 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -2962,8 +2962,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): is_buffer = func.name in ('__getbuffer__', '__releasebuffer__') if (func.is_special and Options.docstrings and func.wrapperbase_cname and not is_buffer): - slot = TypeSlots.method_name_to_slot[func.name] - preprocessor_guard = slot.preprocessor_guard_code() + slot = TypeSlots.method_name_to_slot.get(func.name) + preprocessor_guard = slot.preprocessor_guard_code() if slot else None if preprocessor_guard: code.putln(preprocessor_guard) code.putln('#if CYTHON_COMPILING_IN_CPYTHON') diff --git a/tests/run/ext_auto_richcmp.py b/tests/run/ext_auto_richcmp.py index 3d8f87659..3d940fd60 100644 --- a/tests/run/ext_auto_richcmp.py +++ b/tests/run/ext_auto_richcmp.py @@ -78,8 +78,12 @@ class ClassEq(X): ... else: a >= b Traceback (most recent call last): TypeError... + + >>> print(a.__eq__.__doc__) + EQ """ def __eq__(self, other): + """EQ""" assert 1 <= self.x <= 2 assert isinstance(self, ClassEq), type(self) if isinstance(other, X): @@ -141,8 +145,14 @@ class ClassEqNe(ClassEq): ... else: a >= b Traceback (most recent call last): TypeError... + + #>>> print(a.__eq__.__doc__) + #EQ + >>> print(a.__ne__.__doc__) + NE """ def __ne__(self, other): + """NE""" assert 1 <= self.x <= 2 assert isinstance(self, ClassEqNe), type(self) if isinstance(other, X): @@ -240,8 +250,16 @@ class ClassEqNeGe(ClassEqNe): ... else: a >= 'x' Traceback (most recent call last): TypeError... + + #>>> print(a.__eq__.__doc__) + #EQ + #>>> print(a.__ne__.__doc__) + #NE + >>> print(a.__ge__.__doc__) + GE """ def __ge__(self, other): + """GE""" assert 1 <= self.x <= 2 assert isinstance(self, ClassEqNeGe), type(self) if isinstance(other, X): |