Skip to content

Commit

Permalink
Fix for UnicodeEncodeError on Windows with Python 3.11
Browse files Browse the repository at this point in the history
repr(args) still raised UnicodeEncodeError, this could be due to
removal of Py_UNICODE API. To combat this, we're printing pre-encoded
arguments – less readable, but working.

Note that this doesn't change the fact, that application is bundled
and signed using bash terminal, which should handle utf-8 quite well.
Issue presents itself only on the default powershell.
  • Loading branch information
kkalinowski-reef committed Feb 7, 2023
1 parent 20f0752 commit 95bdef7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion b2/console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,8 @@ def _print_helper(cls, descriptor, descriptor_encoding, descriptor_name, *args):
descriptor_encoding,
)
)
sys.stderr.write("Trying to print: %s\n" % (repr(args),))
args = [arg.encode('ascii', 'backslashreplace').decode() for arg in args]
sys.stderr.write("Trying to print: %s\n" % args)
descriptor.write(' '.join(args))
descriptor.write('\n')

Expand Down

0 comments on commit 95bdef7

Please sign in to comment.