Add binary mode for writing

Useless on Linux, can prevent data corruption on windows.
This commit is contained in:
Florent 2015-09-07 23:56:50 +02:00
commit cf6774afe6

View file

@ -206,7 +206,7 @@ class Boobill(ReplApplication):
print(buf) print(buf)
else: else:
try: try:
with open(dest, 'w') as f: with open(dest, 'wb') as f:
f.write(buf) f.write(buf)
except IOError as e: except IOError as e:
print('Unable to write bill in "%s": %s' % (dest, e), file=self.stderr) print('Unable to write bill in "%s": %s' % (dest, e), file=self.stderr)
@ -223,7 +223,7 @@ class Boobill(ReplApplication):
print(buf) print(buf)
else: else:
try: try:
with open(dest, 'w') as f: with open(dest, 'wb') as f:
f.write(buf) f.write(buf)
except IOError as e: except IOError as e:
print('Unable to write bill in "%s": %s' % (dest, e), file=self.stderr) print('Unable to write bill in "%s": %s' % (dest, e), file=self.stderr)