Commit 1d37f2ae authored by Stefan Behnel's avatar Stefan Behnel

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.
parent 69c04ee7
...@@ -1385,10 +1385,15 @@ class DecoratorTransform(ScopeTrackingTransform, SkipDeclarations): ...@@ -1385,10 +1385,15 @@ class DecoratorTransform(ScopeTrackingTransform, SkipDeclarations):
elif decorator.is_attribute and decorator.obj.name in properties: elif decorator.is_attribute and decorator.obj.name in properties:
handler_name = self._map_property_attribute(decorator.attribute) handler_name = self._map_property_attribute(decorator.attribute)
if handler_name: if handler_name:
assert decorator.obj.name == node.name if decorator.obj.name != node.name:
if len(node.decorators) > 1: # 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._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 # we clear node.decorators, so we need to set the
# is_staticmethod/is_classmethod attributes now # is_staticmethod/is_classmethod attributes now
......
...@@ -34,9 +34,14 @@ cdef class Prop: ...@@ -34,9 +34,14 @@ cdef class Prop:
def prop2(self, value): def prop2(self, value):
pass pass
@prop2.setter
def other_name(self, value):
pass
_ERRORS = """ _ERRORS = """
19:4: Property methods with additional decorators are not supported 19:4: Property methods with additional decorators are not supported
27:4: Property methods with additional decorators are not supported 27:4: Property methods with additional decorators are not supported
33:4: Property methods with additional decorators are not supported 33:4: Property methods with additional decorators are not supported
37:4: Mismatching property names, expected 'prop2', got 'other_name'
""" """
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