Commit e1939379 authored by Stefan Behnel's avatar Stefan Behnel

Py3 fixes

parent e76ea8ef
......@@ -65,7 +65,7 @@ def hash_source_file(path):
# 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):
......
......@@ -3,7 +3,10 @@
#
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
......@@ -54,7 +57,7 @@ def parse_from_strings(name, code, pxds={}, level=None, initial_pos=None):
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)
......
......@@ -131,7 +131,7 @@ class TransitionMap(object):
# 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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment