# tabs by a single space.
import re
text = re.sub("[ \t]+", " ", text)
- hash = new_md5(text).hexdigest()
+ hash = new_md5(text.encode("ASCII")).hexdigest()
return hash
def open_pickled_lexicon(expected_hash):
#
import re
-from cStringIO import StringIO
+try:
+ from cStringIO import BytesIO # Py3 mangled by 2to3 ...
+except ImportError:
+ from cStringIO import StringIO as BytesIO # Py3 mangled by 2to3 ...
from Scanning import PyrexScanner, StringSourceDescriptor
from Symtab import BuiltinScope, ModuleScope
import Symtab
context = StringParseContext([], name)
scope = context.find_module(module_name, pos = initial_pos, need_pxd = 0)
- buf = StringIO(code.encode(encoding))
+ buf = BytesIO(code.encode(encoding))
scanner = PyrexScanner(buf, code_source, source_encoding = encoding,
scope = scope, context = context, initial_pos = initial_pos)
# loop invariant: map[lo] <= code < map[hi] and hi - lo >= 2
while hi - lo >= 4:
# Find midpoint truncated to even index
- mid = ((lo + hi) / 2) & ~1
+ mid = ((lo + hi) // 2) & ~1
if code < map[mid]:
hi = mid
else: