#print "...from", rhs ###
#print "...LHS type", self.type, "ctype", self.ctype() ###
#print "...RHS type", rhs.type, "ctype", rhs.ctype() ###
+ if entry.is_cglobal:
+ code.put_gotref(self.py_result())
if not self.lhs_of_first_assignment:
if entry.is_local and not Options.init_local_none:
initalized = entry.scope.control_flow.get_state((entry.name, 'initalized'), self.pos)
code.put_xdecref(self.result(), self.ctype())
else:
code.put_decref(self.result(), self.ctype())
+ if entry.is_cglobal:
+ code.put_giveref(rhs.py_result())
code.putln('%s = %s;' % (self.result(), rhs.result_as(self.ctype())))
if debug_disposal_code:
print("NameNode.generate_assignment_code:")
env.use_utility_code(Nodes.traceback_utility_code)
code.putln("%s = NULL;" % Naming.retval_cname)
code.put_label(code.return_label)
- code.put_finish_refcount_context(self.pos, env.qualified_name,
- Naming.retval_cname, "NULL")
+ # Disabled because of confusion with refcount of global variables -- run ass2cglobal testcase to see
+ #code.put_finish_refcount_context(self.pos, env.qualified_name,
+ # Naming.retval_cname, "NULL")
+ code.putln("#if CYTHON_REFNANNY")
+ code.putln("if (__pyx_refchk) {};")
+ code.putln("#endif")
code.putln("#if PY_MAJOR_VERSION < 3")
code.putln("return;")
code.putln("#else")
exc_args = "&%s, &%s, &%s" % tuple(self.exc_vars)
code.putln("if (__Pyx_GetException(%s) < 0) %s" % (exc_args,
code.error_goto(self.pos)))
+ for x in self.exc_vars:
+ code.put_gotref(x)
if self.target:
self.exc_value.generate_evaluation_code(code)
self.target.generate_assignment_code(self.exc_value, code)