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