From: Stefan Behnel Date: Mon, 11 Aug 2008 11:13:18 +0000 (+0200) Subject: Py2.6/3.0 import fixes X-Git-Tag: 0.9.8.1~65 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6b760cb3d3dcbc89df5d2eb9a3c249fda22effa0;p=cython.git Py2.6/3.0 import fixes --- diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index a07b640a..1cbde366 100644 --- a/Cython/Compiler/Code.py +++ b/Cython/Compiler/Code.py @@ -10,7 +10,10 @@ from PyrexTypes import py_object_type, typecast from TypeSlots import method_coexist from Scanning import SourceDescriptor from Cython.StringIOTree import StringIOTree -from sets import Set as set +try: + set +except NameError: + from sets import Set as set class FunctionContext(object): # Not used for now, perhaps later diff --git a/Cython/Compiler/Scanning.py b/Cython/Compiler/Scanning.py index 32c833a3..9737f977 100644 --- a/Cython/Compiler/Scanning.py +++ b/Cython/Compiler/Scanning.py @@ -38,7 +38,10 @@ def hash_source_file(path): # Try to calculate a hash code for the given source file. # Returns an empty string if the file cannot be accessed. #print "Hashing", path ### - import md5 + try: + from hashlib import md5 as new_md5 + except ImportError: + from md5 import new as new_md5 try: try: f = open(path, "rU") @@ -54,7 +57,7 @@ def hash_source_file(path): # tabs by a single space. import re text = re.sub("[ \t]+", " ", text) - hash = md5.new(text).hexdigest() + hash = new_md5(text).hexdigest() return hash def open_pickled_lexicon(expected_hash):