7*4, # start of key index
7*4+len(keys)*8, # start of value index
0, 0) # size and offset of hash table
- output += array.array("i", offsets).tostring()
+ output += array.array("i", offsets).tobytes()
output += ids
output += strs
return output
outfile = os.path.splitext(infile)[0] + '.mo'
try:
- lines = open(infile, 'rb').readlines()
+ with open(infile, 'rb') as f:
+ lines = f.readlines()
except IOError as msg:
print(msg, file=sys.stderr)
sys.exit(1)
output = generate()
try:
- open(outfile,"wb").write(output)
+ with open(outfile,"wb") as f:
+ f.write(output)
except IOError as msg:
print(msg, file=sys.stderr)