Show More
@@ -9,6 +9,7 import abc | |||
|
9 | 9 | import functools |
|
10 | 10 | import re |
|
11 | 11 | import tokenize |
|
12 | import warnings | |
|
12 | 13 | from tokenize import untokenize, TokenError |
|
13 | 14 | from io import StringIO |
|
14 | 15 | |
@@ -42,7 +43,16 ESC_SEQUENCES = [ESC_SHELL, ESC_SH_CAP, ESC_HELP ,\ | |||
|
42 | 43 | |
|
43 | 44 | class InputTransformer(metaclass=abc.ABCMeta): |
|
44 | 45 | """Abstract base class for line-based input transformers.""" |
|
45 | ||
|
46 | ||
|
47 | def __init__(self): | |
|
48 | warnings.warn( | |
|
49 | "`InputTransformer` has been deprecated since IPython 7.0" | |
|
50 | " and emit a warnig since IPython 8.31, it" | |
|
51 | " will be removed in the future", | |
|
52 | DeprecationWarning, | |
|
53 | stacklevel=2, | |
|
54 | ) | |
|
55 | ||
|
46 | 56 | @abc.abstractmethod |
|
47 | 57 | def push(self, line): |
|
48 | 58 | """Send a line of input to the transformer, returning the transformed |
@@ -78,6 +88,14 class InputTransformer(metaclass=abc.ABCMeta): | |||
|
78 | 88 | class StatelessInputTransformer(InputTransformer): |
|
79 | 89 | """Wrapper for a stateless input transformer implemented as a function.""" |
|
80 | 90 | def __init__(self, func): |
|
91 | super().__init__() | |
|
92 | warnings.warn( | |
|
93 | "`StatelessInputTransformer` has been deprecated since IPython 7.0" | |
|
94 | " and emit a warnig since IPython 8.31, it" | |
|
95 | " will be removed in the future", | |
|
96 | DeprecationWarning, | |
|
97 | stacklevel=2, | |
|
98 | ) | |
|
81 | 99 | self.func = func |
|
82 | 100 | |
|
83 | 101 | def __repr__(self): |
@@ -96,6 +114,14 class CoroutineInputTransformer(InputTransformer): | |||
|
96 | 114 | """Wrapper for an input transformer implemented as a coroutine.""" |
|
97 | 115 | def __init__(self, coro, **kwargs): |
|
98 | 116 | # Prime it |
|
117 | super().__init__() | |
|
118 | warnings.warn( | |
|
119 | "`CoroutineInputTransformer` has been deprecated since IPython 7.0" | |
|
120 | " and emit a warnig since IPython 8.31, it" | |
|
121 | " will be removed in the future", | |
|
122 | DeprecationWarning, | |
|
123 | stacklevel=2, | |
|
124 | ) | |
|
99 | 125 | self.coro = coro(**kwargs) |
|
100 | 126 | next(self.coro) |
|
101 | 127 | |
@@ -122,6 +148,13 class TokenInputTransformer(InputTransformer): | |||
|
122 | 148 | return an iterable which can be passed to tokenize.untokenize(). |
|
123 | 149 | """ |
|
124 | 150 | def __init__(self, func): |
|
151 | warnings.warn( | |
|
152 | "`CoroutineInputTransformer` has been deprecated since IPython 7.0" | |
|
153 | " and emit a warnig since IPython 8.31, it" | |
|
154 | " will be removed in the future", | |
|
155 | DeprecationWarning, | |
|
156 | stacklevel=2, | |
|
157 | ) | |
|
125 | 158 | self.func = func |
|
126 | 159 | self.buf = [] |
|
127 | 160 | self.reset_tokenizer() |
@@ -167,7 +200,7 class TokenInputTransformer(InputTransformer): | |||
|
167 | 200 | |
|
168 | 201 | class assemble_python_lines(TokenInputTransformer): |
|
169 | 202 | def __init__(self): |
|
170 |
super( |
|
|
203 | super().__init__(None) | |
|
171 | 204 | |
|
172 | 205 | def output(self, tokens): |
|
173 | 206 | return self.reset() |
@@ -320,12 +320,6 class InputSplitterTestCase(unittest.TestCase): | |||
|
320 | 320 | self.isp.push(u'\xc3\xa9') |
|
321 | 321 | self.isp.push(u"u'\xc3\xa9'") |
|
322 | 322 | |
|
323 | @pytest.mark.xfail( | |
|
324 | reason="Bug in python 3.9.8 – bpo 45738", | |
|
325 | condition=sys.version_info in [(3, 11, 0, "alpha", 2)], | |
|
326 | raises=SystemError, | |
|
327 | strict=True, | |
|
328 | ) | |
|
329 | 323 | def test_line_continuation(self): |
|
330 | 324 | """ Test issue #2108.""" |
|
331 | 325 | isp = self.isp |
General Comments 0
You need to be logged in to leave comments.
Login now