提交 fe50ef92 authored 作者: abalkin's avatar abalkin

More python 3.x fixes:

* Suppress 2to3's "next" fixer that conflicts with having non-iterator attributes called "next." Rely on six.next instead. * added python 3 version of hash_from_code.
上级 5704378e
......@@ -14,6 +14,10 @@ try:
except ImportError:
from distutils.core import setup
try:
from distutils.util import Mixin2to3
from lib2to3.refactor import get_fixers_from_package
Mixin2to3.fixer_names = [f for f in get_fixers_from_package('lib2to3.fixes')
if f != 'lib2to3.fixes.fix_next']
from distutils.command.build_py import build_py_2to3 \
as build_py
from distutils.command.build_scripts import build_scripts_2to3 \
......
......@@ -13,8 +13,13 @@ from itertools import izip
import numpy
if sys.version_info[:2] >= (3, 0):
import hashlib
def hash_from_code(msg):
return hashlib.md5(msg.encode()).hexdigest()
if sys.version_info[:2] >= (2, 5):
elif sys.version_info[:2] >= (2, 5):
import hashlib
def hash_from_code(msg):
......
......@@ -13,7 +13,7 @@ import subprocess
import sys
import tempfile
import time
from six import b
from six import b, next
import distutils.sysconfig
......@@ -918,7 +918,7 @@ class ModuleCache(object):
# If we do, then there is no need to even compile it.
duplicated_module = False
# The first compilation step is to yield the source code.
src_code = compile_steps.next()
src_code = next(compile_steps)
module_hash = get_module_hash(src_code, key)
# The op has c_code, so take the lock.
......@@ -973,7 +973,7 @@ class ModuleCache(object):
try:
# The module should be returned by the last
# step of the compilation.
module = compile_steps.next()
module = next(compile_steps)
except StopIteration:
break
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论