Show More
@@ -9,6 +9,7 import abc | |||||
9 | import functools |
|
9 | import functools | |
10 | import re |
|
10 | import re | |
11 | import tokenize |
|
11 | import tokenize | |
|
12 | import warnings | |||
12 | from tokenize import untokenize, TokenError |
|
13 | from tokenize import untokenize, TokenError | |
13 | from io import StringIO |
|
14 | from io import StringIO | |
14 |
|
15 | |||
@@ -43,6 +44,15 ESC_SEQUENCES = [ESC_SHELL, ESC_SH_CAP, ESC_HELP ,\ | |||||
43 | class InputTransformer(metaclass=abc.ABCMeta): |
|
44 | class InputTransformer(metaclass=abc.ABCMeta): | |
44 | """Abstract base class for line-based input transformers.""" |
|
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 | @abc.abstractmethod |
|
56 | @abc.abstractmethod | |
47 | def push(self, line): |
|
57 | def push(self, line): | |
48 | """Send a line of input to the transformer, returning the transformed |
|
58 | """Send a line of input to the transformer, returning the transformed | |
@@ -78,6 +88,14 class InputTransformer(metaclass=abc.ABCMeta): | |||||
78 | class StatelessInputTransformer(InputTransformer): |
|
88 | class StatelessInputTransformer(InputTransformer): | |
79 | """Wrapper for a stateless input transformer implemented as a function.""" |
|
89 | """Wrapper for a stateless input transformer implemented as a function.""" | |
80 | def __init__(self, func): |
|
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 | self.func = func |
|
99 | self.func = func | |
82 |
|
100 | |||
83 | def __repr__(self): |
|
101 | def __repr__(self): | |
@@ -96,6 +114,14 class CoroutineInputTransformer(InputTransformer): | |||||
96 | """Wrapper for an input transformer implemented as a coroutine.""" |
|
114 | """Wrapper for an input transformer implemented as a coroutine.""" | |
97 | def __init__(self, coro, **kwargs): |
|
115 | def __init__(self, coro, **kwargs): | |
98 | # Prime it |
|
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 | self.coro = coro(**kwargs) |
|
125 | self.coro = coro(**kwargs) | |
100 | next(self.coro) |
|
126 | next(self.coro) | |
101 |
|
127 | |||
@@ -122,6 +148,13 class TokenInputTransformer(InputTransformer): | |||||
122 | return an iterable which can be passed to tokenize.untokenize(). |
|
148 | return an iterable which can be passed to tokenize.untokenize(). | |
123 | """ |
|
149 | """ | |
124 | def __init__(self, func): |
|
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 | self.func = func |
|
158 | self.func = func | |
126 | self.buf = [] |
|
159 | self.buf = [] | |
127 | self.reset_tokenizer() |
|
160 | self.reset_tokenizer() | |
@@ -167,7 +200,7 class TokenInputTransformer(InputTransformer): | |||||
167 |
|
200 | |||
168 | class assemble_python_lines(TokenInputTransformer): |
|
201 | class assemble_python_lines(TokenInputTransformer): | |
169 | def __init__(self): |
|
202 | def __init__(self): | |
170 |
super( |
|
203 | super().__init__(None) | |
171 |
|
204 | |||
172 | def output(self, tokens): |
|
205 | def output(self, tokens): | |
173 | return self.reset() |
|
206 | return self.reset() |
@@ -320,12 +320,6 class InputSplitterTestCase(unittest.TestCase): | |||||
320 | self.isp.push(u'\xc3\xa9') |
|
320 | self.isp.push(u'\xc3\xa9') | |
321 | self.isp.push(u"u'\xc3\xa9'") |
|
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 | def test_line_continuation(self): |
|
323 | def test_line_continuation(self): | |
330 | """ Test issue #2108.""" |
|
324 | """ Test issue #2108.""" | |
331 | isp = self.isp |
|
325 | isp = self.isp |
General Comments 0
You need to be logged in to leave comments.
Login now