From 1a3b1fbad534553c965c379bc1fd6f51eabe4b08 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Wed, 8 Oct 2008 02:22:20 -0700 Subject: [PATCH] More struct cleanup. --- Cython/Compiler/PyrexTypes.py | 4 +++- Cython/Compiler/Symtab.py | 8 -------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index b6519df5..e51b0edc 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -953,9 +953,11 @@ class CStructOrUnionType(CType): code.putln("res = PyDict_New(); if (res == NULL) return NULL;") for member in self.scope.var_entries: if member.type.to_py_function and member.type.create_convert_utility_code(env): + interned_name = env.get_string_const(member.name, identifier=True) + env.add_py_string(interned_name) code.putln("member = %s(s.%s); if (member == NULL) goto bad;" % ( member.type.to_py_function, member.cname)) - code.putln("if (PyDict_SetItem(res, %s, member) < 0) goto bad;" % member.py_name.pystring_cname) + code.putln("if (PyDict_SetItem(res, %s, member) < 0) goto bad;" % interned_name.pystring_cname) code.putln("Py_DECREF(member);") else: self.to_py_function = None diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 1547dc82..c166953b 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -359,8 +359,6 @@ class Scope: self.type_entries.append(entry) if not scope and not entry.type.scope: self.check_for_illegal_incomplete_ctypedef(typedef_flag, pos) - if scope and self.outer_scope: - scope.module_scope = self return entry def check_previous_typedef_flag(self, entry, typedef_flag, pos): @@ -1207,8 +1205,6 @@ class GeneratorLocalScope(LocalScope): class StructOrUnionScope(Scope): # Namespace of a C struct or union. - module_scope = None - def __init__(self, name="?"): Scope.__init__(self, name, None, None) @@ -1221,10 +1217,6 @@ class StructOrUnionScope(Scope): type = PyrexTypes.CPtrType(type) entry = self.declare(name, cname, type, pos, visibility) entry.is_variable = 1 - if self.module_scope: - py_name = self.module_scope.get_string_const(name, identifier=True) - self.module_scope.add_py_string(py_name) - entry.py_name = py_name self.var_entries.append(entry) if type.is_pyobject and not allow_pyobject: error(pos, -- 2.26.2