From: Dag Sverre Seljebotn Date: Fri, 25 Jul 2008 10:15:09 +0000 (+0200) Subject: Fixed refcount optimization bug (introduced in refactor of cdef-assignment) X-Git-Tag: 0.9.8.1~49^2~74^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8f1d9228ea930430d3a5d3796bbf18bf8754f14c;p=cython.git Fixed refcount optimization bug (introduced in refactor of cdef-assignment) --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 4f02ef1e..b0c98c66 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1031,20 +1031,21 @@ class NameNode(AtomicExprNode): rhs.generate_disposal_code(code) else: - if self.type.is_pyobject and not self.skip_assignment_decref: + if self.type.is_pyobject: + rhs.make_owned_reference(code) #print "NameNode.generate_assignment_code: to", self.name ### #print "...from", rhs ### #print "...LHS type", self.type, "ctype", self.ctype() ### #print "...RHS type", rhs.type, "ctype", rhs.ctype() ### - rhs.make_owned_reference(code) - if entry.is_local and not Options.init_local_none: - initalized = entry.scope.control_flow.get_state((entry.name, 'initalized'), self.pos) - if initalized is True: + if not self.skip_assignment_decref: + if entry.is_local and not Options.init_local_none: + initalized = entry.scope.control_flow.get_state((entry.name, 'initalized'), self.pos) + if initalized is True: + code.put_decref(self.result_code, self.ctype()) + elif initalized is None: + code.put_xdecref(self.result_code, self.ctype()) + else: code.put_decref(self.result_code, self.ctype()) - elif initalized is None: - code.put_xdecref(self.result_code, self.ctype()) - else: - code.put_decref(self.result_code, self.ctype()) code.putln('%s = %s;' % (self.result_code, rhs.result_as(self.ctype()))) if debug_disposal_code: print("NameNode.generate_assignment_code:")