invalidate type cache in Py2.6+
authorStefan Behnel <scoder@users.berlios.de>
Sat, 24 May 2008 08:33:28 +0000 (10:33 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Sat, 24 May 2008 08:33:28 +0000 (10:33 +0200)
Cython/Compiler/Nodes.py

index db1370a061802d5eb5337229c6ceac7abd602837..89e874375a0de49151d05c83243c4a3659359c7d 100644 (file)
@@ -2101,6 +2101,11 @@ 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: