Fix #245, crash on cimported struct -> object.
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 15 Oct 2009 09:00:28 +0000 (02:00 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 15 Oct 2009 09:00:28 +0000 (02:00 -0700)
Cython/Compiler/PyrexTypes.py
Cython/Compiler/Symtab.py
tests/run/crashT245.h
tests/run/crashT245.pyx

index 99b081c763eb2947aba3c06f508d8c7e813280a7..09ac13d2a43258a6fc6bda86031703f0ceb9290c 100644 (file)
@@ -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)
index 0d2360e74680a6b5a9d38f4a4153cb9fd4ba3f42..e661eff1c456de20222a47d567d9becb0a61d466 100644 (file)
@@ -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):
index 8a615517807a958ffa5a8e8d8f16534215cd166b..51b4e16bde113d5757d87b874a046f3cda827f39 100644 (file)
@@ -1,4 +1,4 @@
 typedef struct {
-    int x
+    int x;
 } MyStruct;
 
index 70228cd8ed8fb228c9fe1b4a73e70c2bc505d121..3b01e4bde5a2ab4509c2e77c0b30edd0e4669509 100644 (file)
@@ -1,10 +1,10 @@
-cimport crashT245_pxd
-
-"""
+__doc__ = """
 >>> f()
 {'x': 1}
 """
 
+cimport crashT245_pxd
+
 def f():
     cdef crashT245_pxd.MyStruct s
     s.x = 1