Python 3 support: .compat.xrange

This commit is contained in:
Kamil Cholewiński 2015-04-10 10:39:21 +02:00
parent 0082e13048
commit 5befcaecf3
3 changed files with 8 additions and 5 deletions

View File

@ -9,9 +9,11 @@ IS_PY3 = sys.version_info[0] == 3
if IS_PY2:
from StringIO import StringIO
unicode, str, bytes, basestring = unicode, str, str, basestring
xrange = xrange
elif IS_PY3:
from io import StringIO
unicode, str, bytes, basestring = str, bytes, bytes, str
xrange = range
else:
raise NotImplementedError('welcome to the future, I guess. (report this)')

View File

@ -34,6 +34,9 @@ from __future__ import print_function
import gc
import sys
from .compat import xrange
__all__ = ['get_all', 'GCToggler', 'toggle_gc', 'toggle_gc_postcollect']

View File

@ -15,11 +15,9 @@ import operator
from math import log as math_log
from itertools import chain, islice
try:
from compat import make_sentinel
_MISSING = make_sentinel(var_name='_MISSING')
except ImportError:
_MISSING = object()
from .compat import make_sentinel, xrange
_MISSING = make_sentinel(var_name='_MISSING')
# TODO: expose splaylist?
__all__ = ['BList', 'BarrelList']