py3: Fix passing stdout/stderr to RotatingLog not working

This commit is contained in:
Kovid Goyal 2019-04-17 09:27:57 +05:30
parent 3a9dd02e04
commit 03e862aa70
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -322,7 +322,14 @@ class RotatingStream(object):
self.set_output()
def set_output(self):
self.stream = share_open(self.filename, 'ab', -1 if iswindows else 1) # line buffered
if ispy3:
if iswindows:
self.stream = share_open(self.filename, 'ab')
else:
# see https://bugs.python.org/issue27805
self.stream = open(os.open(self.filename, os.O_WRONLY|os.O_APPEND|os.O_CREAT|os.O_CLOEXEC), 'wb')
else:
self.stream = share_open(self.filename, 'ab', -1 if iswindows else 1) # line buffered
try:
self.current_pos = self.stream.tell()
except EnvironmentError: