1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
From 5d1d04febe3a7996260e6ad860703e450205b16e Mon Sep 17 00:00:00 2001
From: Stefano Rivera <stefanor@debian.org>
Date: Sun, 11 Oct 2015 21:49:59 +0200
Subject: 04_use_hashlib.diff
Patch-Name: 04_use_hashlib.diff
---
cherrypy/filters/sessionfilter.py | 4 ++--
cherrypy/lib/cptools.py | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/cherrypy/filters/sessionfilter.py b/cherrypy/filters/sessionfilter.py
index b8812ec..e05df1c 100644
--- a/cherrypy/filters/sessionfilter.py
+++ b/cherrypy/filters/sessionfilter.py
@@ -30,7 +30,7 @@ try:
except ImportError:
import pickle
import random
-import sha
+import hashlib
import time
import thread
import threading
@@ -450,7 +450,7 @@ except (AttributeError, NotImplementedError):
# os.urandom not available until Python 2.4. Fall back to random.random.
def generate_session_id():
"""Return a new session id."""
- return sha.new('%s' % random.random()).hexdigest()
+ return hashlib.sha('%s' % random.random()).hexdigest()
else:
def generate_session_id():
"""Return a new session id."""
diff --git a/cherrypy/lib/cptools.py b/cherrypy/lib/cptools.py
index 30e0155..cfc954e 100644
--- a/cherrypy/lib/cptools.py
+++ b/cherrypy/lib/cptools.py
@@ -1,6 +1,6 @@
"""Tools which both CherryPy and application developers may invoke."""
-import md5
+import hashlib
import mimetools
import mimetypes
mimetypes.init()
@@ -99,7 +99,7 @@ def validate_etags(autotags=False):
if (not etag) and autotags:
if status == 200:
etag = response.collapse_body()
- etag = '"%s"' % md5.new(etag).hexdigest()
+ etag = '"%s"' % hashlib.md5(etag).hexdigest()
response.headers['ETag'] = etag
response.ETag = etag
|