py23: raise Py23Error when using 'xrange'
see https://github.com/behdad/fonttools/pull/600#issuecomment-216935319
This commit is contained in:
parent
d3cfcbb5ed
commit
a796b03366
@ -6,7 +6,11 @@ import sys
|
||||
|
||||
__all__ = ['basestring', 'unicode', 'unichr', 'byteord', 'bytechr', 'BytesIO',
|
||||
'StringIO', 'UnicodeIO', 'strjoin', 'bytesjoin', 'tobytes', 'tostr',
|
||||
'tounicode', 'Tag', 'open', 'range', 'xrange']
|
||||
'tounicode', 'Tag', 'open', 'range', 'xrange', 'Py23Error']
|
||||
|
||||
|
||||
class Py23Error(NotImplementedError):
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
@ -241,14 +245,15 @@ def open(file, mode='r', buffering=-1, encoding=None, errors=None,
|
||||
file, mode, buffering, encoding, errors, newline, closefd)
|
||||
|
||||
|
||||
# always use iterator whether one uses 'range' (py3) or 'xrange' (py2)
|
||||
# always use iterator for 'range' on both py 2 and 3
|
||||
try:
|
||||
xrange = xrange
|
||||
range = xrange
|
||||
except NameError:
|
||||
xrange = range
|
||||
range = range
|
||||
|
||||
def xrange(*args, **kwargs):
|
||||
raise Py23Error("'xrange' is not defined. Use 'range' instead.")
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user