From 2b1548d8305519aecf9dda9e9a6021da7706f6c2 Mon Sep 17 00:00:00 2001 From: Craig Citro Date: Tue, 9 Mar 2010 16:51:51 -0800 Subject: [PATCH] Fix for autotestdict & property not playing well together. --- Cython/Compiler/AnalysedTreeTransforms.py | 13 ++++++++++++- Cython/Compiler/Nodes.py | 2 +- tests/run/extpropertyref.pyx | 5 +++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/AnalysedTreeTransforms.py b/Cython/Compiler/AnalysedTreeTransforms.py index 4ce100f7..f7ef59bd 100644 --- a/Cython/Compiler/AnalysedTreeTransforms.py +++ b/Cython/Compiler/AnalysedTreeTransforms.py @@ -6,6 +6,7 @@ from PyrexTypes import py_object_type from Builtin import dict_type from StringEncoding import EncodedString import Naming +import Symtab class AutoTestDictTransform(ScopeTrackingTransform): # Handles autotestdict directive @@ -82,7 +83,17 @@ class AutoTestDictTransform(ScopeTrackingTransform): type=py_object_type, is_py_attr=True, is_temp=True) - name = "%s.%s" % (clsname, node.entry.name) + if isinstance(node.entry.scope, Symtab.PropertyScope): + new_node = AttributeNode(pos, obj=parent, + attribute=node.entry.scope.name, + type=py_object_type, + is_py_attr=True, + is_temp=True) + parent = new_node + name = "%s.%s.%s" % (clsname, node.entry.scope.name, + node.entry.name) + else: + name = "%s.%s" % (clsname, node.entry.name) else: assert False getfunc = AttributeNode(pos, obj=parent, diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index c80b0c0f..de912990 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1726,7 +1726,7 @@ class PyArgDeclNode(Node): class DecoratorNode(Node): # A decorator # - # decorator NameNode or CallNode + # decorator NameNode or CallNode or AttributeNode child_attrs = ['decorator'] diff --git a/tests/run/extpropertyref.pyx b/tests/run/extpropertyref.pyx index 1b783e1b..f2f73af4 100644 --- a/tests/run/extpropertyref.pyx +++ b/tests/run/extpropertyref.pyx @@ -3,12 +3,17 @@ cdef class Spam: property eggs: def __get__(self): + """ + This is the docstring for Spam.eggs.__get__ + """ return 42 def tomato(): """ >>> tomato() 42 + >>> sorted(__test__.keys()) + [u'Spam.eggs.__get__ (line 5)', u'tomato (line 11)'] """ cdef Spam spam cdef object lettuce -- 2.26.2