diff --git a/python_modules/codegen.py b/python_modules/codegen.py index affe5bc..0a13fdd 100644 --- a/python_modules/codegen.py +++ b/python_modules/codegen.py @@ -128,13 +128,13 @@ class CodeWriter: return if self.at_line_start: - self.out.write(u" " * self.indentation) + self.out.write(" " * self.indentation) self.at_line_start = False self.out.write(s) return self def newline(self): - self.out.write(u"\n") + self.out.write("\n") self.at_line_start = True return self diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py index d68dc67..05234d8 100644 --- a/python_modules/ptypes.py +++ b/python_modules/ptypes.py @@ -111,7 +111,7 @@ def fix_attributes(attribute_list, valid_attributes=valid_attributes_generic): attrs[name] = lst # only one output attribute can be set - if len(output_attributes.intersection(attrs.keys())) > 1: + if len(output_attributes.intersection(list(attrs.keys()))) > 1: raise Exception("Multiple output type attributes specified %s" % output_attrs) return attrs @@ -508,7 +508,7 @@ class ArrayType(Type): # a constant length array in the C structure is used) or a pointer # (in this case the pointer allocate the array). if (not self.is_constant_length() - and len(output_attributes.intersection(member.attributes.keys())) == 0 + and len(output_attributes.intersection(list(member.attributes.keys()))) == 0 and not member.member_type.is_pointer()): raise Exception("Array length must be a constant or some output specifiers must be set") # These attribute corresponds to specific structure size @@ -1005,7 +1005,7 @@ class MessageType(ContainerType): if self.name == None: cms = list(self.reverse_members.keys()) if len(cms) != 1: - raise "Unknown typename for message" + raise Exception("Unknown typename for message") cm = cms[0] channelname = cm.channel.member_name if channelname == None: @@ -1025,7 +1025,7 @@ class MessageType(ContainerType): if self.name == None: cms = list(self.reverse_members.keys()) if len(cms) != 1: - raise "Unknown typename for message" + raise Exception("Unknown typename for message") cm = cms[0] channelname = cm.channel.member_name if channelname == None: diff --git a/spice_codegen.py b/spice_codegen.py index 6d8d97a..579ba84 100755 --- a/spice_codegen.py +++ b/spice_codegen.py @@ -277,7 +277,7 @@ current: except: print('type %s' % t, file=sys.stderr) print(writer.getvalue(), file=sys.stderr) - traceback.print_exc(sys.stderr) + traceback.print_exc(file=sys.stderr) sys.exit(1) def generate_declarations():