From 781a25512b107828aff71998c19f2fa4dbf471c1 Mon Sep 17 00:00:00 2001 From: "Sergey G. Brester" Date: Fri, 6 Mar 2020 19:04:39 +0100 Subject: [PATCH 1/4] travis CI: add 3.9-dev as target --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 1f218c81..59a50313 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ matrix: - python: 3.6 - python: 3.7 - python: 3.8 + - python: 3.9-dev - python: pypy3.5 before_install: - echo "running under $TRAVIS_PYTHON_VERSION" From 55e76c0b807e87f6a04d459bb9c59da33c98572b Mon Sep 17 00:00:00 2001 From: "Sergey G. Brester" Date: Fri, 6 Mar 2020 19:41:16 +0100 Subject: [PATCH 2/4] restore isAlive method removed in python 3.9 --- fail2ban/server/jailthread.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fail2ban/server/jailthread.py b/fail2ban/server/jailthread.py index d0430367..94f34542 100644 --- a/fail2ban/server/jailthread.py +++ b/fail2ban/server/jailthread.py @@ -120,3 +120,6 @@ class JailThread(Thread): ## python 2.x replace binding of private __bootstrap method: if sys.version_info < (3,): # pragma: 3.x no cover JailThread._Thread__bootstrap = JailThread._JailThread__bootstrap +## python 3.9, restore isAlive method: +elif not hasattr(JailThread, 'isAlive'): # pragma: 2.x no cover + JailThread.isAlive = JailThread.is_alive From 9d7388e68448e9294e568a8ad21599e719c914b0 Mon Sep 17 00:00:00 2001 From: "Sergey G. Brester" Date: Fri, 6 Mar 2020 20:04:18 +0100 Subject: [PATCH 3/4] Thread: is_alive instead of isAlive (removed in py-3.9) --- fail2ban/tests/sockettestcase.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fail2ban/tests/sockettestcase.py b/fail2ban/tests/sockettestcase.py index 4e14ece5..8cd22a41 100644 --- a/fail2ban/tests/sockettestcase.py +++ b/fail2ban/tests/sockettestcase.py @@ -86,7 +86,7 @@ class Socket(LogCaptureTestCase): def _stopServerThread(self): serverThread = self.serverThread # wait for end of thread : - Utils.wait_for(lambda: not serverThread.isAlive() + Utils.wait_for(lambda: not serverThread.is_alive() or serverThread.join(Utils.DEFAULT_SLEEP_TIME), unittest.F2B.maxWaitTime(10)) self.serverThread = None @@ -97,7 +97,7 @@ class Socket(LogCaptureTestCase): self.server.close() # wait for end of thread : self._stopServerThread() - self.assertFalse(serverThread.isAlive()) + self.assertFalse(serverThread.is_alive()) # clean : self.server.stop() self.assertFalse(self.server.isActive()) @@ -138,7 +138,7 @@ class Socket(LogCaptureTestCase): self.server.stop() # wait for end of thread : self._stopServerThread() - self.assertFalse(serverThread.isAlive()) + self.assertFalse(serverThread.is_alive()) self.assertFalse(self.server.isActive()) self.assertFalse(os.path.exists(self.sock_name)) @@ -179,7 +179,7 @@ class Socket(LogCaptureTestCase): self.server.stop() # wait for end of thread : self._stopServerThread() - self.assertFalse(serverThread.isAlive()) + self.assertFalse(serverThread.is_alive()) def testLoopErrors(self): # replace poll handler to produce error in loop-cycle: @@ -215,7 +215,7 @@ class Socket(LogCaptureTestCase): self.server.stop() # wait for end of thread : self._stopServerThread() - self.assertFalse(serverThread.isAlive()) + self.assertFalse(serverThread.is_alive()) self.assertFalse(self.server.isActive()) self.assertFalse(os.path.exists(self.sock_name)) From d4da9afd7fefcbba94f95d636832c3821073657e Mon Sep 17 00:00:00 2001 From: "Sergey G. Brester" Date: Fri, 6 Mar 2020 20:29:48 +0100 Subject: [PATCH 4/4] Update ChangeLog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 3d7e73be..36c15891 100644 --- a/ChangeLog +++ b/ChangeLog @@ -32,6 +32,7 @@ ver. 0.10.6-dev (20??/??/??) - development edition IPv6-capable now. ### Fixes +* python 3.9 compatibility (and Travis CI support) * restoring a large number (500+ depending on files ulimit) of current bans when using PyPy fixed * manual ban is written to database, so can be restored by restart (gh-2647) * `filter.d/common.conf`: avoid substitute of default values in related `lt_*` section, `__prefix_line`