summaryrefslogtreecommitdiff
path: root/cherrypy/lib/cptools.py
diff options
context:
space:
mode:
Diffstat (limited to 'cherrypy/lib/cptools.py')
-rw-r--r--cherrypy/lib/cptools.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/cherrypy/lib/cptools.py b/cherrypy/lib/cptools.py
index eefd1ae7..5092d2ed 100644
--- a/cherrypy/lib/cptools.py
+++ b/cherrypy/lib/cptools.py
@@ -1,7 +1,11 @@
"""Functions for builtin CherryPy tools."""
import logging
-import md5
+try:
+ # Python 2.5+
+ from hashlib import md5
+except ImportError:
+ from md5 import new as md5
import re
import cherrypy
@@ -40,7 +44,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"' % md5(etag).hexdigest()
response.headers['ETag'] = etag
response.ETag = etag