Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions repls/subprocess_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import subprocess
import os
import io
import sys
from .repl import Repl
import signal
Expand Down Expand Up @@ -218,16 +219,15 @@ def read_bytes(self):
else:
# this is windows specific problem, that you cannot tell if there
# are more bytes ready, so we read only 1 at a times

while True:
byte = self.popen.stdout.read(1)
if byte == b'\r':
# f'in HACK, for \r\n -> \n translation on windows
# I tried universal_endlines but it was pain and misery! :'(
continue
return byte



## This way it is possible to read more bytes on Windows the same
## way as on POSIX.
with io.open(self.popen.stdout.fileno(), 'rb', closefd=False) as out:
byte = out.read1(4096)
# f'in HACK, for \r\n -> \n translation on windows
# I tried universal_endlines but it was pain and misery! :'(
byte = byte.replace(b'\r', b'')
return byte

def write_bytes(self, bytes):
si = self.popen.stdin
Expand Down