From 51d1bd1c2ee154aec17e5e9328725b5d713d6c46 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Thu, 15 Oct 2009 02:00:28 -0700 Subject: [PATCH] Fix #245, crash on cimported struct -> object. --- Cython/Compiler/PyrexTypes.py | 5 +++-- Cython/Compiler/Symtab.py | 1 + tests/run/crashT245.h | 2 +- tests/run/crashT245.pyx | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 99b081c7..09ac13d2 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -1535,6 +1535,8 @@ class CStructOrUnionType(CType): # typedef_flag boolean # packed boolean + # entry Entry + is_struct_or_union = 1 has_attributes = 1 @@ -1563,8 +1565,7 @@ class CStructOrUnionType(CType): self.to_py_function = None self._convert_code = False return False - entry = env.lookup(self.name) - forward_decl = (entry.visibility != 'extern') + forward_decl = (self.entry.visibility != 'extern') self._convert_code = StructUtilityCode(self, forward_decl) env.use_utility_code(self._convert_code) diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 0d2360e7..e661eff1 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -363,6 +363,7 @@ class Scope(object): entry = self.declare_type(name, type, pos, cname, visibility = visibility, defining = scope is not None) self.sue_entries.append(entry) + type.entry = entry else: if not (entry.is_type and entry.type.is_struct_or_union and entry.type.kind == kind): diff --git a/tests/run/crashT245.h b/tests/run/crashT245.h index 8a615517..51b4e16b 100644 --- a/tests/run/crashT245.h +++ b/tests/run/crashT245.h @@ -1,4 +1,4 @@ typedef struct { - int x + int x; } MyStruct; diff --git a/tests/run/crashT245.pyx b/tests/run/crashT245.pyx index 70228cd8..3b01e4bd 100644 --- a/tests/run/crashT245.pyx +++ b/tests/run/crashT245.pyx @@ -1,10 +1,10 @@ -cimport crashT245_pxd - -""" +__doc__ = """ >>> f() {'x': 1} """ +cimport crashT245_pxd + def f(): cdef crashT245_pxd.MyStruct s s.x = 1 -- 2.26.2