Show More
@@ -545,9 +545,9 b' class IPythonInputSplitter(InputSplitter):' | |||
|
545 | 545 | def transforms_in_use(self): |
|
546 | 546 | """Transformers, excluding logical line transformers if we're in a |
|
547 | 547 | Python line.""" |
|
548 |
t = self.physical_line_transforms |
|
|
548 | t = self.physical_line_transforms[:] | |
|
549 | 549 | if not self.within_python_line: |
|
550 | t += self.logical_line_transforms | |
|
550 | t += [self.assemble_logical_lines] + self.logical_line_transforms | |
|
551 | 551 | return t + [self.assemble_python_lines] + self.python_line_transforms |
|
552 | 552 | |
|
553 | 553 | def reset(self): |
@@ -556,6 +556,7 b' class IPythonInputSplitter(InputSplitter):' | |||
|
556 | 556 | self._buffer_raw[:] = [] |
|
557 | 557 | self.source_raw = '' |
|
558 | 558 | self.transformer_accumulating = False |
|
559 | self.within_python_line = False | |
|
559 | 560 | for t in self.transforms: |
|
560 | 561 | t.reset() |
|
561 | 562 | |
@@ -685,11 +686,11 b' class IPythonInputSplitter(InputSplitter):' | |||
|
685 | 686 | if line is None: |
|
686 | 687 | return _accumulating(transformer) |
|
687 | 688 | |
|
689 | if not self.within_python_line: | |
|
688 | 690 | line = self.assemble_logical_lines.push(line) |
|
689 | 691 | if line is None: |
|
690 | 692 | return _accumulating('acc logical line') |
|
691 | 693 | |
|
692 | if not self.within_python_line: | |
|
693 | 694 | for transformer in self.logical_line_transforms: |
|
694 | 695 | line = transformer.push(line) |
|
695 | 696 | if line is None: |
@@ -180,10 +180,12 b' def assemble_logical_lines():' | |||
|
180 | 180 | |
|
181 | 181 | parts = [] |
|
182 | 182 | while line is not None: |
|
183 | parts.append(line.rstrip('\\')) | |
|
184 | if not line.endswith('\\'): | |
|
183 | if line.endswith('\\') and (not has_comment(line)): | |
|
184 | parts.append(line[:-1]) | |
|
185 | line = (yield None) # Get another line | |
|
186 | else: | |
|
187 | parts.append(line) | |
|
185 | 188 | break |
|
186 | line = (yield None) | |
|
187 | 189 | |
|
188 | 190 | # Output |
|
189 | 191 |
line = ' |
@@ -190,12 +190,19 b' syntax_ml = \\' | |||
|
190 | 190 | ], |
|
191 | 191 | ], |
|
192 | 192 | |
|
193 | multiline_datastructure = | |
|
193 | multiline_datastructure_prompt = | |
|
194 | 194 | [ [('>>> a = [1,','a = [1,'), |
|
195 | 195 | ('... 2]','2]'), |
|
196 | 196 | ], |
|
197 | 197 | ], |
|
198 | 198 | |
|
199 | multiline_datastructure = | |
|
200 | [ [('b = ("%s"', None), | |
|
201 | ('# comment', None), | |
|
202 | ('%foo )', 'b = ("%s"\n# comment\n%foo )'), | |
|
203 | ], | |
|
204 | ], | |
|
205 | ||
|
199 | 206 | leading_indent = |
|
200 | 207 | [ [(' print "hi"','print "hi"'), |
|
201 | 208 | ], |
@@ -262,7 +269,7 b' def test_classic_prompt():' | |||
|
262 | 269 | tt.check_pairs(transform_and_reset(ipt.classic_prompt), syntax['classic_prompt']) |
|
263 | 270 | for example in syntax_ml['classic_prompt']: |
|
264 | 271 | transform_checker(example, ipt.classic_prompt) |
|
265 | for example in syntax_ml['multiline_datastructure']: | |
|
272 | for example in syntax_ml['multiline_datastructure_prompt']: | |
|
266 | 273 | transform_checker(example, ipt.classic_prompt) |
|
267 | 274 | |
|
268 | 275 | |
@@ -280,6 +287,8 b' def test_assemble_logical_lines():' | |||
|
280 | 287 | (u"12 *\\", None), |
|
281 | 288 |
(None, u"a = |
|
282 | 289 | ], |
|
290 | [(u"# foo\\", u"# foo\\"), # Comments can't be continued like this | |
|
291 | ], | |
|
283 | 292 | ] |
|
284 | 293 | for example in tests: |
|
285 | 294 | transform_checker(example, ipt.assemble_logical_lines) |
@@ -300,7 +309,7 b' def test_assemble_python_lines():' | |||
|
300 | 309 | (u"2,", None), |
|
301 | 310 | (None, u"a = [1,\n2,"), |
|
302 | 311 | ], |
|
303 | ] | |
|
312 | ] + syntax_ml['multiline_datastructure'] | |
|
304 | 313 | for example in tests: |
|
305 | 314 | transform_checker(example, ipt.assemble_python_lines) |
|
306 | 315 |
General Comments 0
You need to be logged in to leave comments.
Login now