diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2017-10-03 20:29:54 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2017-10-03 20:29:54 +0200 |
commit | 1d37f2ae8c0754a9c823f5ca88641778858f9204 (patch) | |
tree | be49c9c769751be371e11a0b11cdbcbaa6d5a8b0 /Cython/Compiler/ParseTreeTransforms.py | |
parent | 69c04ee7efd868b32726ca694d41439ba674a468 (diff) | |
download | cython-1d37f2ae8c0754a9c823f5ca88641778858f9204.tar.gz |
Turn compiler assertion into an error since it's triggered by user code.
Considered to make it a warning, but CPython's forgiving behaviour seems unhelpful. Can still make it a warning later.
Closed #1905.
Diffstat (limited to 'Cython/Compiler/ParseTreeTransforms.py')
-rw-r--r-- | Cython/Compiler/ParseTreeTransforms.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index 7ee9861a8..f74ac3beb 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -1385,10 +1385,15 @@ class DecoratorTransform(ScopeTrackingTransform, SkipDeclarations): elif decorator.is_attribute and decorator.obj.name in properties: handler_name = self._map_property_attribute(decorator.attribute) if handler_name: - assert decorator.obj.name == node.name - if len(node.decorators) > 1: + if decorator.obj.name != node.name: + # CPython does not generate an error or warning, but not something useful either. + error(decorator_node.pos, + "Mismatching property names, expected '%s', got '%s'" % ( + decorator.obj.name, node.name)) + elif len(node.decorators) > 1: return self._reject_decorated_property(node, decorator_node) - return self._add_to_property(properties, node, handler_name, decorator_node) + else: + return self._add_to_property(properties, node, handler_name, decorator_node) # we clear node.decorators, so we need to set the # is_staticmethod/is_classmethod attributes now |