[PATCH] D63254: [lit] Fix UnicodeEncodeError when test commands contain non-ASCII chars
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 14 06:18:10 PDT 2019
ruiu accepted this revision.
ruiu added a comment.
LGTM
================
Comment at: llvm/utils/lit/lit/TestRunner.py:1137-1141
if litConfig.isWindows and not isWin32CMDEXE:
- mode += 'b' # Avoid CRLFs when writing bash scripts.
- f = open(script, mode)
+ mode += 'b' # Avoid CRLFs when writing bash scripts.
+ elif sys.version_info > (3,0):
+ open_kwargs['encoding'] = 'utf-8'
+ f = open(script, mode, **open_kwargs)
----------------
I'd perhaps write this this way,
f = None
if litConfig.isWindows and not isWin32CMDEXE:
f = open(script, 'wb')
elif sys.version_info > (3,0):
f = open(script, 'w', encoding='utf-8')
else
f = open(script, 'w')
so that it is clear what values are passed to `open`, but that's probably my personal preference.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63254/new/
https://reviews.llvm.org/D63254
More information about the llvm-commits
mailing list