rev_entries.reverse()
for entry in rev_entries:
if entry.visibility != 'extern':
- if entry.type.is_pyobject:
+ if entry.type.is_pyobject and entry.used:
code.put_var_decref_clear(entry)
if Options.generate_cleanup_code >= 3:
code.putln("/*--- Type import cleanup code ---*/")
# variables to None.
for entry in env.var_entries:
if entry.visibility != 'extern':
- if entry.type.is_pyobject:
+ if entry.type.is_pyobject and entry.used:
code.put_init_var_to_py_none(entry)
def generate_c_function_export_code(self, env, code):
handler(decl)
continue # Remove declaration
raise PostParseError(decl.pos, ERR_CDEF_INCLASS)
+ first_assignment = self.scope_type != 'module'
stats.append(SingleAssignmentNode(node.pos,
lhs=NameNode(node.pos, name=declbase.name),
- rhs=declbase.default, first=True))
+ rhs=declbase.default, first=first_assignment))
declbase.default = None
newdecls.append(decl)
node.declarators = newdecls