Craig, could you please review and test this?
--
Lisandro Dalcin
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
diff -r a46fde95b18a Cython/Compiler/AnalysedTreeTransforms.py
--- a/Cython/Compiler/AnalysedTreeTransforms.py Thu Mar 11 13:42:02 2010 -0300
+++ b/Cython/Compiler/AnalysedTreeTransforms.py Thu Mar 11 14:52:45 2010 -0300
@@ -61,6 +61,9 @@
if isinstance(node, CFuncDefNode) and not node.py_func:
# skip non-cpdef cdef functions
return node
+ if (self.scope_type == 'cclass' and
+ isinstance(node.entry.scope, Symtab.PropertyScope)):
+ return node
pos = self.testspos
if self.scope_type == 'module':
@@ -83,17 +86,7 @@
type=py_object_type,
is_py_attr=True,
is_temp=True)
- 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)
+ name = "%s.%s" % (clsname, node.entry.name)
else:
assert False
getfunc = AttributeNode(pos, obj=parent,
@@ -104,3 +97,22 @@
self.add_test(node.pos, name, getfunc)
return node
+ def visit_PropertyNode(self, node):
+ if node.doc:
+ pos = self.testspos
+ mod = ModuleRefNode(pos)
+ clsname = self.scope_node.class_name
+ parent = AttributeNode(pos, obj=mod,
+ attribute=clsname,
+ type=py_object_type,
+ is_py_attr=True,
+ is_temp=True)
+ getfunc = AttributeNode(pos, obj=parent,
+ attribute=node.name,
+ type=py_object_type,
+ is_py_attr=True,
+ is_temp=True)
+ name = "%s.%s" % (clsname, node.name)
+ self.add_test(node.pos, name, getfunc)
+ return node
+
diff -r a46fde95b18a tests/run/autotestdict.pyx
--- a/tests/run/autotestdict.pyx Thu Mar 11 13:42:02 2010 -0300
+++ b/tests/run/autotestdict.pyx Thu Mar 11 14:52:45 2010 -0300
@@ -12,12 +12,13 @@
>>> items.sort()
>>> for key, value in items:
... print('%s ; %s' % (key, value))
-MyCdefClass.cpdef_method (line 78) ; >>> add_log("cpdef class method")
-MyCdefClass.method (line 75) ; >>> add_log("cdef class method")
-MyClass.method (line 65) ; >>> add_log("class method")
-doc_without_test (line 47) ; Some docs
-mycpdeffunc (line 53) ; >>> add_log("cpdef")
-myfunc (line 44) ; >>> add_log("def")
+MyCdefClass.cpdef_method (line 79) ; >>> add_log("cpdef class method")
+MyCdefClass.method (line 76) ; >>> add_log("cdef class method")
+MyCdefClass.property (line 114) ; >>> add_log("cdef class property")
+MyClass.method (line 66) ; >>> add_log("class method")
+doc_without_test (line 48) ; Some docs
+mycpdeffunc (line 54) ; >>> add_log("cpdef")
+myfunc (line 45) ; >>> add_log("def")
"""
@@ -33,7 +34,7 @@
def all_tests_run():
log.sort()
- assert log == [u'cdef class method', u'class method', u'cpdef', u'def'], log
+ assert log == [u'cdef class method', u'cdef class property', u'class method', u'cpdef', u'def'], log
def add_log(s):
log.append(unicode(s))
@@ -110,4 +111,31 @@
False
"""
+ property property:
+ """>>> add_log("cdef class property")"""
+ def __get__(self):
+ """
+ Please don't include me!
+
+ >>> True
+ False
+ """
+ pass
+ def __set__(self, value):
+ """
+ Please don't include me!
+
+ >>> True
+ False
+ """
+ pass
+ def __del__(self):
+ """
+ Please don't include me!
+
+ >>> True
+ False
+ """
+ pass
+
cdeffunc()
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev