mirror of
https://git.rtems.org/rtems-tools/
synced 2025-10-16 00:07:25 +08:00
rtemstoolkit/execute: Handle unicode input on python2
- Allow unicode as a type on python2. The unicode type is not present on python3 so make the support conditional. - Add some more diag prints to aid debugging. Closes #3964
This commit is contained in:
@@ -139,12 +139,20 @@ class execute(object):
|
|||||||
tmp = bytes('temp', sys.stdin.encoding)
|
tmp = bytes('temp', sys.stdin.encoding)
|
||||||
except:
|
except:
|
||||||
encoding = False
|
encoding = False
|
||||||
|
input_types = [str, bytes]
|
||||||
|
try:
|
||||||
|
# Unicode is not valid in python3, not added to the list
|
||||||
|
input_types += [unicode]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
if trace_threads:
|
if trace_threads:
|
||||||
print('execute:_writethread: call input', input)
|
print('execute:_writethread: call input', input)
|
||||||
lines = input()
|
lines = input()
|
||||||
if type(lines) == str or type(lines) == bytes:
|
if trace_threads:
|
||||||
|
print('execute:_writethread: input returned:', type(lines))
|
||||||
|
if type(lines) in input_types:
|
||||||
try:
|
try:
|
||||||
if encoding:
|
if encoding:
|
||||||
lines = bytes(lines, sys.stdin.encoding)
|
lines = bytes(lines, sys.stdin.encoding)
|
||||||
@@ -216,6 +224,9 @@ class execute(object):
|
|||||||
sd = sd[:-1]
|
sd = sd[:-1]
|
||||||
if len(sd) > 0:
|
if len(sd) > 0:
|
||||||
for l in sd:
|
for l in sd:
|
||||||
|
if trace_threads:
|
||||||
|
print('execute:_readthread: output-line:',
|
||||||
|
count, type(l))
|
||||||
_output_line(l + '\n', exe, prefix, out, count)
|
_output_line(l + '\n', exe, prefix, out, count)
|
||||||
count += 1
|
count += 1
|
||||||
if count > 10:
|
if count > 10:
|
||||||
|
Reference in New Issue
Block a user