mirror of
https://github.com/curl/curl.git
synced 2025-03-31 16:00:35 +08:00
tests/util.py: fix compatibility with Python 2
Backporting the Python 3 implementation of setStream to ClosingFileHandler as a fallback within Python 2. Reported-by: Jay Satiro Fixes #6259 Closes #6270
This commit is contained in:
parent
41b3b830f1
commit
753a2c758a
@ -46,6 +46,21 @@ class ClosingFileHandler(logging.StreamHandler):
|
||||
super(ClosingFileHandler, self).emit(record)
|
||||
self.setStream(None)
|
||||
|
||||
def setStream(self, stream):
|
||||
setStream = getattr(super(ClosingFileHandler, self), 'setStream', None)
|
||||
if callable(setStream):
|
||||
return setStream(stream)
|
||||
if stream is self.stream:
|
||||
result = None
|
||||
else:
|
||||
result = self.stream
|
||||
self.acquire()
|
||||
try:
|
||||
self.flush()
|
||||
self.stream = stream
|
||||
finally:
|
||||
self.release()
|
||||
return result
|
||||
|
||||
class TestData(object):
|
||||
def __init__(self, data_folder):
|
||||
|
Loading…
x
Reference in New Issue
Block a user