Skip to content

Commit 46f6a1b

Browse files
committed
[LSP] Print LSP output as ASCII
`sys.stdout` seems to be `ascii` on some configurations, eg. Jenkins. When the string has UTF8 characters, this results in: ``` UnicodeEncodeError: 'ascii' codec can't encode character... ``` The output here is really just for debugging test failures, so just encode the string as ASCII and output that instead. Resolves rdar://105608805.
1 parent d7977c3 commit 46f6a1b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test-sourcekit-lsp/test-sourcekit-lsp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ def main():
136136
print('==== OUTPUT ====')
137137

138138
skargs = [args.sourcekit_lsp, '--sync', '-Xclangd', '-sync']
139-
p = subprocess.Popen(skargs, stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True, encoding='utf-8')
139+
p = subprocess.Popen(skargs, stdin=subprocess.PIPE, stdout=subprocess.PIPE, encoding='utf-8')
140140
out, _ = p.communicate(lsp.script)
141-
print(out)
141+
print(out.encode(encoding='ascii', errors='replace')
142142
print('')
143143

144144
if p.returncode == 0:

0 commit comments

Comments
 (0)