moved method cache invalidation next to dict update, as proposed by Lisandro
authorStefan Behnel <scoder@users.berlios.de>
Mon, 26 May 2008 19:34:41 +0000 (21:34 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Mon, 26 May 2008 19:34:41 +0000 (21:34 +0200)
Cython/Compiler/ExprNodes.py
Cython/Compiler/Nodes.py

index 542322576e11483eafcc074d77548a0539ab5416..1114643d58e088221119495508c389d9585c8f9d 100644 (file)
@@ -989,6 +989,12 @@ class NameNode(AtomicExprNode):
                         namespace,
                         self.interned_cname,
                         rhs.py_result()))
+                # in Py2.6+, we need to invalidate the method cache
+                typeptr_cname = entry.scope.parent_type.typeptr_cname
+                code.putln("#if PY_VERSION_HEX >= 0x02060000")
+                code.putln("(%s)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;" %
+                           typeptr_cname)
+                code.putln("#endif")
             else: 
                 code.put_error_if_neg(self.pos,
                     'PyObject_SetAttr(%s, %s, %s)' % (
index 89e874375a0de49151d05c83243c4a3659359c7d..db1370a061802d5eb5337229c6ceac7abd602837 100644 (file)
@@ -2101,11 +2101,6 @@ class CClassDefNode(StatNode, BlockNode):
         # default values of method arguments.
         if self.body:
             self.body.generate_execution_code(code)
-            # in Py2.6+, we need to invalidate the type cache
-            code.putln("#if PY_VERSION_HEX >= 0x02060000")
-            code.putln("(%s)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;" %
-                       self.entry.type.typeptr_cname)
-            code.putln("#endif")
             
     def annotate(self, code):
         if self.body: