##// END OF EJS Templates
Fix references to xrange
Thomas Kluyver -
Show More
@@ -445,7 +445,7 b' class IOPubChannel(ZMQSocketChannel):'
445 445 # We do the IOLoop callback process twice to ensure that the IOLoop
446 446 # gets to perform at least one full poll.
447 447 stop_time = time.time() + timeout
448 for i in xrange(2):
448 for i in range(2):
449 449 self._flushed = False
450 450 self.ioloop.add_callback(self._flush)
451 451 while not self._flushed and time.time() < stop_time:
@@ -93,7 +93,7 b' def get_parent(globals, level):'
93 93 globals['__package__'] = name = modname[:lastdot]
94 94
95 95 dot = len(name)
96 for x in xrange(level, 1, -1):
96 for x in range(level, 1, -1):
97 97 try:
98 98 dot = name.rindex('.', 0, dot)
99 99 except ValueError:
@@ -708,10 +708,8 b' except NameError:'
708 708 #: printers for builtin types
709 709 _type_pprinters = {
710 710 int: _repr_pprint,
711 long: _repr_pprint,
712 711 float: _repr_pprint,
713 712 str: _repr_pprint,
714 unicode: _repr_pprint,
715 713 tuple: _seq_pprinter_factory('(', ')', tuple),
716 714 list: _seq_pprinter_factory('[', ']', list),
717 715 dict: _dict_pprinter_factory('{', '}', dict),
@@ -734,8 +732,10 b' _type_pprinters = {'
734 732 try:
735 733 _type_pprinters[types.DictProxyType] = _dict_pprinter_factory('<dictproxy {', '}>')
736 734 _type_pprinters[types.ClassType] = _type_pprint
737 except AttributeError: # Python 3
738 pass
735 _type_pprinters[long] = _repr_pprint
736 _type_pprinters[unicode] = _repr_pprint
737 except (AttributeError, NameError): # Python 3
738 _type_pprinters[bytes] = _repr_pprint
739 739
740 740 try:
741 741 _type_pprinters[xrange] = _repr_pprint
@@ -40,7 +40,7 b' from IPython.utils.coloransi import TermColors'
40 40 from IPython.utils.jsonutil import rekey
41 41 from IPython.utils.localinterfaces import localhost, is_local_ip
42 42 from IPython.utils.path import get_ipython_dir
43 from IPython.utils.py3compat import cast_bytes, string_types
43 from IPython.utils.py3compat import cast_bytes, string_types, xrange
44 44 from IPython.utils.traitlets import (HasTraits, Integer, Instance, Unicode,
45 45 Dict, List, Bool, Set, Any)
46 46 from IPython.external.decorator import decorator
@@ -56,11 +56,6 b' from IPython.kernel.zmq import serialize'
56 56 from .asyncresult import AsyncResult, AsyncHubResult
57 57 from .view import DirectView, LoadBalancedView
58 58
59 if sys.version_info[0] >= 3:
60 # xrange is used in a couple 'isinstance' tests in py2
61 # should be just 'range' in 3k
62 xrange = range
63
64 59 #--------------------------------------------------------------------------
65 60 # Decorators for Client methods
66 61 #--------------------------------------------------------------------------
@@ -259,7 +259,7 b' _random_ports = set()'
259 259 def select_random_ports(n):
260 260 """Selects and return n random ports that are available."""
261 261 ports = []
262 for i in xrange(n):
262 for i in range(n):
263 263 sock = socket.socket()
264 264 sock.bind(('', 0))
265 265 while sock.getsockname()[1] in _random_ports:
@@ -368,7 +368,7 b' class QtAnsiCodeProcessor(AnsiCodeProcessor):'
368 368 if color.value() >= 127:
369 369 # Colors appropriate for a terminal with a light background. For
370 370 # now, only use non-bright colors...
371 for i in xrange(8):
371 for i in range(8):
372 372 self.default_color_map[i + 8] = self.default_color_map[i]
373 373
374 374 # ...and replace white with black.
@@ -9,6 +9,8 b''
9 9 # the file COPYING, distributed as part of this software.
10 10 #-----------------------------------------------------------------------------
11 11
12 from .py3compat import xrange
13
12 14 def uniq_stable(elems):
13 15 """uniq_stable(elems) -> list
14 16
@@ -92,6 +92,7 b' if sys.version_info[0] >= 3:'
92 92 return s.isidentifier()
93 93
94 94 open = orig_open
95 xrange = range
95 96
96 97 MethodType = types.MethodType
97 98
@@ -166,6 +167,8 b' else:'
166 167 def __exit__(self, etype, value, traceback):
167 168 self.f.close()
168 169
170 xrange = xrange
171
169 172 def MethodType(func, instance):
170 173 return types.MethodType(func, instance, type(instance))
171 174
@@ -29,7 +29,6 b' from IPython.external.path import path'
29 29 from IPython.testing.skipdoctest import skip_doctest_py3, skip_doctest
30 30 from IPython.utils import py3compat
31 31
32
33 32 #-----------------------------------------------------------------------------
34 33 # Declarations
35 34 #-----------------------------------------------------------------------------
@@ -615,7 +614,7 b' class DollarFormatter(FullEvalFormatter):'
615 614
616 615 def _chunks(l, n):
617 616 """Yield successive n-sized chunks from l."""
618 for i in xrange(0, len(l), n):
617 for i in py3compat.xrange(0, len(l), n):
619 618 yield l[i:i+n]
620 619
621 620
@@ -16,6 +16,8 b' Utilities for timing code execution.'
16 16
17 17 import time
18 18
19 from .py3compat import xrange
20
19 21 #-----------------------------------------------------------------------------
20 22 # Code
21 23 #-----------------------------------------------------------------------------
General Comments 0
You need to be logged in to leave comments. Login now