From: Stefan Behnel Date: Mon, 26 May 2008 19:34:41 +0000 (+0200) Subject: moved method cache invalidation next to dict update, as proposed by Lisandro X-Git-Tag: 0.9.8rc1~11^2~10^2~15^2~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f00f3b5459129e9af97adcecf7cac136fc5b4b62;p=cython.git moved method cache invalidation next to dict update, as proposed by Lisandro --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 54232257..1114643d 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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)' % ( diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 89e87437..db1370a0 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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: