Python 3 fix.
authorRobert Bradshaw <robertwb@gmail.com>
Sun, 16 Jun 2013 08:21:51 +0000 (01:21 -0700)
committerRobert Bradshaw <robertwb@gmail.com>
Sun, 16 Jun 2013 08:33:01 +0000 (01:33 -0700)
Cython/Compiler/Code.py

index af89dbe..1bd7747 100644 (file)
@@ -9,7 +9,6 @@ cython.declare(os=object, re=object, operator=object,
                Utils=object, SourceDescriptor=object, StringIOTree=object,
                DebugFlags=object, basestring=object)
 
-from md5 import md5
 import os
 import re
 import sys
@@ -17,6 +16,11 @@ from string import Template
 import operator
 import textwrap
 
+try:
+    import hashlib
+except ImportError:
+    import md5 as hashlib
+
 import Naming
 import Options
 import StringEncoding
@@ -1527,7 +1531,7 @@ class CCodeWriter(object):
     def put_or_include(self, code, name):
         if code:
             if self.globalstate.common_utility_include_dir and len(code) > 1042:
-                include_file = "%s_%s.h" % (name, md5(code).hexdigest())
+                include_file = "%s_%s.h" % (name, hashlib.md5(code).hexdigest())
                 path = os.path.join(self.globalstate.common_utility_include_dir, include_file)
                 if not os.path.exists(path):
                     tmp_path = '%s.tmp%s' % (path, os.getpid())