Skip to content

Commit

Permalink
tools: make pty_helper.py python3-compatible
Browse files Browse the repository at this point in the history
Fixes: #29166

PR-URL: #29167
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
bnoordhuis authored and targos committed Aug 20, 2019
1 parent 5c5ef4e commit acdc21b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/pseudo-tty/pty_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ def pipe(sfd, dfd):
if dfd == STDOUT:
# Work around platform quirks. Some platforms echo ^D as \x04
# (AIX, BSDs) and some don't (Linux).
filt = lambda c: ord(c) > 31 or c in '\t\n\r\f'
#
# The comparison against b' '[0] is because |data| is
# a string in python2 but a bytes object in python3.
filt = lambda c: c >= b' '[0] or c in b'\t\n\r\f'
data = filter(filt, data)
data = bytes(data)

while data:
try:
Expand Down

0 comments on commit acdc21b

Please sign in to comment.