diff options
| author | Xtreak <tir.karthi@gmail.com> | 2020-01-05 19:25:21 +0530 |
|---|---|---|
| committer | Chris Dent <cdent@anticdent.org> | 2020-01-05 13:55:21 +0000 |
| commit | 7b06a520ba24bec27ae242db92c4ceea22173420 (patch) | |
| tree | 0c5f9268039d0a464b96ae6506b4e6833a825c7b /paste/auth | |
| parent | 104d8ad3f89462dab32c37d0fbdf3c728ffd3223 (diff) | |
| download | paste-git-7b06a520ba24bec27ae242db92c4ceea22173420.tar.gz | |
Fix deprecation warnings (#41)
* Use is_alive instead of isAlive for Python 3.9 compatibility.
* Use encodebytes instead of deprecated encodestring.
* Fix Python 2 and 3 compatibility for base64.
Diffstat (limited to 'paste/auth')
| -rw-r--r-- | paste/auth/cookie.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/paste/auth/cookie.py b/paste/auth/cookie.py index 8f11d1b..d00f17b 100644 --- a/paste/auth/cookie.py +++ b/paste/auth/cookie.py @@ -144,10 +144,17 @@ class AuthCookieSigner(object): if six.PY3: content = content.encode('utf8') timestamp = timestamp.encode('utf8') - cookie = base64.encodestring( - 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: |
