diff --git a/ipykernel/iostream.py b/ipykernel/iostream.py index a1e13845..5c2818dc 100644 --- a/ipykernel/iostream.py +++ b/ipykernel/iostream.py @@ -29,6 +29,8 @@ MASTER = 0 CHILD = 1 +PIPE_BUFFER_SIZE = 1000 + # ----------------------------------------------------------------------------- # IO classes # ----------------------------------------------------------------------------- @@ -367,11 +369,11 @@ def _watch_pipe_fd(self): """ try: - bts = os.read(self._fid, 1000) + bts = os.read(self._fid, PIPE_BUFFER_SIZE) while bts and self._should_watch: - self.write(bts.decode()) + self.write(bts.decode(errors='replace')) os.write(self._original_stdstream_copy, bts) - bts = os.read(self._fid, 1000) + bts = os.read(self._fid, PIPE_BUFFER_SIZE) except Exception: self._exc = sys.exc_info()