Skip to content

Commit

Permalink
handle bytes and bytearray codec outputs in cq-cli.py
Browse files Browse the repository at this point in the history
  • Loading branch information
justbuchanan committed Oct 20, 2023
1 parent 649587e commit e947afc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cq-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,14 @@ def main():
if outfile == None:
print(converted)
else:
with open(outfile, 'w') as file:
file.write(converted)
if isinstance(converted, str):
with open(outfile, 'w') as file:
file.write(converted)
elif isinstance(converted, (bytes, bytearray)):
with open(outfile, 'wb') as file:
file.write(converted)
else:
raise TypeError("Expected converted output to be str, bytes, or bytearray. Got '%s'" % type(converted).__name__)

except Exception:
out_tb = traceback.format_exc()
Expand Down

0 comments on commit e947afc

Please sign in to comment.