Skip to content

Commit

Permalink
Encode output inside mako cmd and write as binary
Browse files Browse the repository at this point in the history
This change is a proposed fix for sqlalchemy#376
  • Loading branch information
ni-balexand authored Feb 15, 2023
1 parent 272f5d8 commit ba40dbe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mako/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ def cmdline(argv=None):
_exit()
else:
if output_file:
open(output_file, "wt", encoding=output_encoding).write(rendered)
if output_encoding is None:
encoded_output = rendered.encode()
else:
encoded_output = rendered.encode(output_encoding)
open(output_file, "wb").write(encoded_output)
else:
sys.stdout.write(rendered)

Expand Down

0 comments on commit ba40dbe

Please sign in to comment.