Skip to content

Commit

Permalink
Fix opening the output file in either normal or binary mode
Browse files Browse the repository at this point in the history
Fix the etree in python lxml wanting to have the file opened in the 'wb'
mode. Fixes the 'TypeError: write() argument must be str, not bytes'
error message but retains compatibility if lxml would be missing. Closes
issues tjfontaine#26 and tjfontaine#28
  • Loading branch information
nolltre committed Jan 19, 2021
1 parent 0384693 commit 72d5267
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion airprint-generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def generate(self):
if self.directory:
fname = os.path.join(self.directory, fname)

f = open(fname, 'w')
f = open(fname, 'wb' if etree else 'w')

if etree:
tree.write(f, pretty_print=True, xml_declaration=True, encoding="UTF-8")
Expand Down

0 comments on commit 72d5267

Please sign in to comment.