Commit 51d1bd1c authored by Robert Bradshaw's avatar Robert Bradshaw

Fix #245, crash on cimported struct -> object.

parent 4d4d29d8
...@@ -1535,6 +1535,8 @@ class CStructOrUnionType(CType): ...@@ -1535,6 +1535,8 @@ class CStructOrUnionType(CType):
# typedef_flag boolean # typedef_flag boolean
# packed boolean # packed boolean
# entry Entry
is_struct_or_union = 1 is_struct_or_union = 1
has_attributes = 1 has_attributes = 1
...@@ -1563,8 +1565,7 @@ class CStructOrUnionType(CType): ...@@ -1563,8 +1565,7 @@ class CStructOrUnionType(CType):
self.to_py_function = None self.to_py_function = None
self._convert_code = False self._convert_code = False
return False return False
entry = env.lookup(self.name) forward_decl = (self.entry.visibility != 'extern')
forward_decl = (entry.visibility != 'extern')
self._convert_code = StructUtilityCode(self, forward_decl) self._convert_code = StructUtilityCode(self, forward_decl)
env.use_utility_code(self._convert_code) env.use_utility_code(self._convert_code)
......
...@@ -363,6 +363,7 @@ class Scope(object): ...@@ -363,6 +363,7 @@ class Scope(object):
entry = self.declare_type(name, type, pos, cname, entry = self.declare_type(name, type, pos, cname,
visibility = visibility, defining = scope is not None) visibility = visibility, defining = scope is not None)
self.sue_entries.append(entry) self.sue_entries.append(entry)
type.entry = entry
else: else:
if not (entry.is_type and entry.type.is_struct_or_union if not (entry.is_type and entry.type.is_struct_or_union
and entry.type.kind == kind): and entry.type.kind == kind):
......
typedef struct { typedef struct {
int x int x;
} MyStruct; } MyStruct;
cimport crashT245_pxd __doc__ = """
"""
>>> f() >>> f()
{'x': 1} {'x': 1}
""" """
cimport crashT245_pxd
def f(): def f():
cdef crashT245_pxd.MyStruct s cdef crashT245_pxd.MyStruct s
s.x = 1 s.x = 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment