Show More
@@ -10,12 +10,13 b' This defines a callable class that IPython uses for `sys.displayhook`.' | |||
|
10 | 10 | from __future__ import print_function |
|
11 | 11 | |
|
12 | 12 | import sys |
|
13 |
import io |
|
|
13 | import io as _io | |
|
14 | import tokenize | |
|
14 | 15 | |
|
15 | 16 | from IPython.core.formatters import _safe_get_formatter_method |
|
16 | 17 | from traitlets.config.configurable import Configurable |
|
17 | 18 | from IPython.utils import io |
|
18 | from IPython.utils.py3compat import builtin_mod | |
|
19 | from IPython.utils.py3compat import builtin_mod, cast_unicode_py2 | |
|
19 | 20 | from traitlets import Instance, Float |
|
20 | 21 | from IPython.utils.warn import warn |
|
21 | 22 | |
@@ -85,21 +86,22 b' class DisplayHook(Configurable):' | |||
|
85 | 86 | """Should we silence the display hook because of ';'?""" |
|
86 | 87 | # do not print output if input ends in ';' |
|
87 | 88 | |
|
88 | cell = self.shell.history_manager.input_hist_parsed[self.prompt_count] | |
|
89 | sio = io.StringIO(cell) | |
|
89 | try: | |
|
90 | cell = cast_unicode_py2(self.shell.history_manager.input_hist_parsed[-1]) | |
|
91 | except IndexError: | |
|
92 | # some uses of ipshellembed may fail here | |
|
93 | return False | |
|
94 | ||
|
95 | sio = _io.StringIO(cell) | |
|
90 | 96 | tokens = list(tokenize.generate_tokens(sio.readline)) |
|
91 | 97 | |
|
92 | try: | |
|
93 | 98 |
|
|
94 |
|
|
|
99 | if token[0] in (tokenize.ENDMARKER, tokenize.COMMENT): | |
|
95 | 100 |
|
|
96 |
|
|
|
101 | if (token[0] == tokenize.OP) and (token[1] == ';'): | |
|
97 | 102 |
|
|
98 | 103 |
|
|
99 | 104 |
|
|
100 | except IndexError: | |
|
101 | # some uses of ipshellembed may fail here | |
|
102 | return False | |
|
103 | 105 | |
|
104 | 106 | def start_displayhook(self): |
|
105 | 107 | """Start the displayhook, initializing resources.""" |
@@ -27,7 +27,7 b' def test_deepreload_numpy():' | |||
|
27 | 27 | # Standard exclusions: |
|
28 | 28 | 'sys', 'os.path', builtin_mod_name, '__main__', |
|
29 | 29 | # Test-related exclusions: |
|
30 | 'unittest', 'UserDict', | |
|
30 | 'unittest', 'UserDict', '_collections_abc', 'tokenize' | |
|
31 | 31 | ] |
|
32 | 32 | |
|
33 | 33 | # `collections` builtin shall not be reloaded to avoid failure |
General Comments 0
You need to be logged in to leave comments.
Login now