Skip to content

Commit 6c6e60e

Browse files
rlehfeldcomrumino
authored andcommitted
when taking ownership of stdin and stdout in PipeStream, the stdin and stdout must be replaced by devnull as on one hand the code executed could write to it but also we will close the channels and thus cause exit code failures
1 parent 827dd48 commit 6c6e60e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

rpyc/core/stream.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,10 @@ def from_std(cls):
326326
327327
:returns: a :class:`PipeStream` instance
328328
"""
329-
return cls(sys.stdin, sys.stdout)
329+
pipestream = cls(sys.stdin, sys.stdout)
330+
sys.stdin = os.open(os.devnull, os.O_RDWR)
331+
sys.stdout = sys.stdin
332+
return pipestream
330333

331334
@classmethod
332335
def create_pair(cls):
@@ -405,7 +408,10 @@ def __init__(self, incoming, outgoing):
405408

406409
@classmethod
407410
def from_std(cls):
408-
return cls(sys.stdin, sys.stdout)
411+
pipestream = cls(sys.stdin, sys.stdout)
412+
sys.stdin = os.open(os.devnull, os.O_RDWR)
413+
sys.stdout = sys.stdin
414+
return pipestream
409415

410416
@classmethod
411417
def create_pair(cls):

rpyc/lib/colls.py

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def __getitem__(self, key):
3737
obj = self._dict[key]()
3838
if obj is None:
3939
raise KeyError(key)
40-
self[key] = obj
4140
return obj
4241

4342
def __setitem__(self, key, value):

0 commit comments

Comments
 (0)