Commit a22a4487 authored by Stefan Behnel's avatar Stefan Behnel

fix struct handling in Py3

parent 893efcd0
......@@ -3528,9 +3528,10 @@ class DictNode(ExprNode):
error(item.key.pos, "Invalid struct field identifier")
item.key = IdentifierStringNode(item.key.pos, value="<error>")
else:
member = dst_type.scope.lookup_here(item.key.value)
key = str(item.key.value) # converts string literals to unicode in Py3
member = dst_type.scope.lookup_here(key)
if not member:
error(item.key.pos, "struct '%s' has no field '%s'" % (dst_type, item.key.value))
error(item.key.pos, "struct '%s' has no field '%s'" % (dst_type, key))
else:
value = item.value
if isinstance(value, CoerceToPyTypeNode):
......
......@@ -1358,7 +1358,8 @@ class CStructOrUnionType(CType):
def __eq__(self, other):
try:
return self.name == other.name
return (isinstance(other, CStructOrUnionType) and
self.name == other.name)
except AttributeError:
return False
......@@ -1370,6 +1371,14 @@ class CStructOrUnionType(CType):
# *some* kind of order
return False
def __hash__(self):
try:
return self.__hashval
except AttributeError:
hashval = self.__hashval = hash(self.cname) ^ (sum([
hash(field.name) for field in self.scope.var_entries]) % 0xffff)
return hashval
def is_complete(self):
return self.scope is not None
......
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