From 7de1dce495a56ab767d7e40e56c76d022460e2ef Mon Sep 17 00:00:00 2001 From: karthikeyan Date: Sat, 4 Jan 2020 11:23:09 +0530 Subject: [PATCH 1/3] Use is_alive instead of isAlive for Python 3.9 compatibility. --- paste/httpserver.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paste/httpserver.py b/paste/httpserver.py index e8d512fa..79468f30 100755 --- a/paste/httpserver.py +++ b/paste/httpserver.py @@ -952,7 +952,7 @@ def shutdown(self, force_quit_timeout=0): hung_workers = [] for worker in self.workers: worker.join(0.5) - if worker.isAlive(): + if worker.is_alive(): hung_workers.append(worker) zombies = [] for thread_id in self.dying_threads: @@ -969,10 +969,10 @@ def shutdown(self, force_quit_timeout=0): timed_out = False need_force_quit = bool(zombies) for worker in self.workers: - if not timed_out and worker.isAlive(): + if not timed_out and worker.is_alive(): timed_out = True worker.join(force_quit_timeout) - if worker.isAlive(): + if worker.is_alive(): print("Worker %s won't die" % worker) need_force_quit = True if need_force_quit: From 155b5cc55239de5770ca6fe41c015248ce1708a3 Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan Date: Sat, 4 Jan 2020 11:26:38 +0530 Subject: [PATCH 2/3] Use encodebytes instead of deprecated encodestring. --- paste/auth/cookie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paste/auth/cookie.py b/paste/auth/cookie.py index 8f11d1bc..6e3009e0 100644 --- a/paste/auth/cookie.py +++ b/paste/auth/cookie.py @@ -144,7 +144,7 @@ def sign(self, content): if six.PY3: content = content.encode('utf8') timestamp = timestamp.encode('utf8') - cookie = base64.encodestring( + cookie = base64.encodebytes( hmac.new(self.secret, content, sha1).digest() + timestamp + content) From 8f9a8e077e5b8f4fe01911e008cff85c54285905 Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan Date: Sat, 4 Jan 2020 11:45:39 +0530 Subject: [PATCH 3/3] Fix Python 2 and 3 compatibility for base64. --- paste/auth/cookie.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/paste/auth/cookie.py b/paste/auth/cookie.py index 6e3009e0..d00f17b3 100644 --- a/paste/auth/cookie.py +++ b/paste/auth/cookie.py @@ -144,10 +144,17 @@ def sign(self, content): if six.PY3: content = content.encode('utf8') timestamp = timestamp.encode('utf8') - cookie = base64.encodebytes( - hmac.new(self.secret, content, sha1).digest() + - timestamp + - content) + + if six.PY3: + cookie = base64.encodebytes( + hmac.new(self.secret, content, sha1).digest() + + timestamp + + content) + else: + cookie = base64.encodestring( + hmac.new(self.secret, content, sha1).digest() + + timestamp + + content) cookie = cookie.replace(b"/", b"_").replace(b"=", b"~") cookie = cookie.replace(b'\n', b'').replace(b'\r', b'') if len(cookie) > self.maxlen: