capture: remove unused FDCapture tmpfile argument

This commit is contained in:
Ran Benita 2020-04-15 16:24:07 +03:00
parent 2695b41df3
commit 02c95ea624
1 changed files with 9 additions and 12 deletions

View File

@ -506,7 +506,7 @@ class FDCaptureBinary:
EMPTY_BUFFER = b"" EMPTY_BUFFER = b""
_state = None _state = None
def __init__(self, targetfd, tmpfile=None): def __init__(self, targetfd):
self.targetfd = targetfd self.targetfd = targetfd
try: try:
@ -530,22 +530,19 @@ class FDCaptureBinary:
self.targetfd_save = os.dup(targetfd) self.targetfd_save = os.dup(targetfd)
if targetfd == 0: if targetfd == 0:
assert not tmpfile, "cannot set tmpfile with stdin" self.tmpfile = open(os.devnull)
tmpfile = open(os.devnull)
self.syscapture = SysCapture(targetfd) self.syscapture = SysCapture(targetfd)
else: else:
if tmpfile is None: self.tmpfile = EncodedFile(
tmpfile = EncodedFile( TemporaryFile(buffering=0),
TemporaryFile(buffering=0), encoding="utf-8",
encoding="utf-8", errors="replace",
errors="replace", write_through=True,
write_through=True, )
)
if targetfd in patchsysdict: if targetfd in patchsysdict:
self.syscapture = SysCapture(targetfd, tmpfile) self.syscapture = SysCapture(targetfd, self.tmpfile)
else: else:
self.syscapture = NoCapture() self.syscapture = NoCapture()
self.tmpfile = tmpfile
def __repr__(self): def __repr__(self):
return "<{} {} oldfd={} _state={!r} tmpfile={!r}>".format( return "<{} {} oldfd={} _state={!r} tmpfile={!r}>".format(