gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnurl] 392/411: tests/util.py: fix compatibility with Python 2


From: gnunet
Subject: [gnurl] 392/411: tests/util.py: fix compatibility with Python 2
Date: Wed, 13 Jan 2021 01:23:27 +0100

This is an automated email from the git hooks/post-receive script.

nikita pushed a commit to branch master
in repository gnurl.

commit 753a2c758aafcf3220367436e0244bd090806d2d
Author: Marc Hoersken <info@marc-hoersken.de>
AuthorDate: Mon Nov 30 22:16:21 2020 +0100

    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
---
 tests/util.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tests/util.py b/tests/util.py
index 2ac6ff132..70f6b4351 100755
--- a/tests/util.py
+++ b/tests/util.py
@@ -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):

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]