Show More
@@ -536,14 +536,13 b' class IPythonInputSplitter(InputSplitter):' | |||
|
536 | 536 | self.transformer_accumulating = False |
|
537 | 537 | self.within_python_line = False |
|
538 | 538 | |
|
539 | last_exc = None | |
|
540 | 539 | for t in self.transforms: |
|
541 | 540 | try: |
|
542 | 541 | t.reset() |
|
543 |
except SyntaxError |
|
|
544 | last_exc = e | |
|
545 | if last_exc is not None: | |
|
546 |
|
|
|
542 | except SyntaxError: | |
|
543 | # Nothing that calls reset() expects to handle transformer | |
|
544 | # errors | |
|
545 | pass | |
|
547 | 546 | |
|
548 | 547 | def flush_transformers(self): |
|
549 | 548 | def _flush(transform, out): |
@@ -560,18 +559,19 b' class IPythonInputSplitter(InputSplitter):' | |||
|
560 | 559 | if out is not None: |
|
561 | 560 | self._store(out) |
|
562 | 561 | |
|
563 |
def |
|
|
564 |
"""Return input |
|
|
562 | def raw_reset(self): | |
|
563 | """Return raw input only and perform a full reset. | |
|
565 | 564 | """ |
|
566 | self.flush_transformers() | |
|
567 | out = self.source | |
|
568 | out_r = self.source_raw | |
|
565 | out = self.source_raw | |
|
569 | 566 | self.reset() |
|
570 |
return out |
|
|
567 | return out | |
|
571 | 568 | |
|
572 | 569 | def source_reset(self): |
|
573 | self.flush_transformers() | |
|
574 | return super(IPythonInputSplitter, self).source_reset() | |
|
570 | try: | |
|
571 | self.flush_transformers() | |
|
572 | return self.source | |
|
573 | finally: | |
|
574 | self.reset() | |
|
575 | 575 | |
|
576 | 576 | def push_accepts_more(self): |
|
577 | 577 | if self.transformer_accumulating: |
@@ -583,8 +583,12 b' class IPythonInputSplitter(InputSplitter):' | |||
|
583 | 583 | """Process and translate a cell of input. |
|
584 | 584 | """ |
|
585 | 585 | self.reset() |
|
586 | self.push(cell) | |
|
587 | return self.source_reset() | |
|
586 | try: | |
|
587 | self.push(cell) | |
|
588 | self.flush_transformers() | |
|
589 | return self.source | |
|
590 | finally: | |
|
591 | self.reset() | |
|
588 | 592 | |
|
589 | 593 | def push(self, lines): |
|
590 | 594 | """Push one or more lines of IPython input. |
@@ -2635,8 +2635,7 b' class InteractiveShell(SingletonConfigurable):' | |||
|
2635 | 2635 | preprocessing_exc_tuple = None |
|
2636 | 2636 | try: |
|
2637 | 2637 | # Static input transformations |
|
2638 |
self.input_transformer_manager. |
|
|
2639 | cell = self.input_transformer_manager.source_reset() | |
|
2638 | cell = self.input_transformer_manager.transform_cell(raw_cell) | |
|
2640 | 2639 | except SyntaxError: |
|
2641 | 2640 | preprocessing_exc_tuple = sys.exc_info() |
|
2642 | 2641 | cell = raw_cell # cell has to exist so it can be stored/logged |
@@ -412,7 +412,8 b' class IPythonInputTestCase(InputSplitterTestCase):' | |||
|
412 | 412 | continue |
|
413 | 413 | |
|
414 | 414 | isp.push(raw+'\n') |
|
415 |
|
|
|
415 | out_raw = isp.source_raw | |
|
416 | out = isp.source_reset() | |
|
416 | 417 | self.assertEqual(out.rstrip(), out_t, |
|
417 | 418 | tt.pair_fail_msg.format("inputsplitter",raw, out_t, out)) |
|
418 | 419 | self.assertEqual(out_raw.rstrip(), raw.rstrip()) |
@@ -431,7 +432,8 b' class IPythonInputTestCase(InputSplitterTestCase):' | |||
|
431 | 432 | isp.push(lraw) |
|
432 | 433 | raw_parts.append(lraw) |
|
433 | 434 | |
|
434 |
|
|
|
435 | out_raw = isp.source_raw | |
|
436 | out = isp.source_reset() | |
|
435 | 437 | out_t = '\n'.join(out_t_parts).rstrip() |
|
436 | 438 | raw = '\n'.join(raw_parts).rstrip() |
|
437 | 439 | self.assertEqual(out.rstrip(), out_t) |
@@ -498,7 +500,8 b" if __name__ == '__main__':" | |||
|
498 | 500 | # Here we just return input so we can use it in a test suite, but a |
|
499 | 501 | # real interpreter would instead send it for execution somewhere. |
|
500 | 502 | #src = isp.source; raise EOFError # dbg |
|
501 |
|
|
|
503 | raw = isp.source_raw | |
|
504 | src = isp.source_reset() | |
|
502 | 505 | print('Input source was:\n', src) |
|
503 | 506 | print('Raw source was:\n', raw) |
|
504 | 507 | except EOFError: |
@@ -545,9 +548,7 b' class CellMagicsCommon(object):' | |||
|
545 | 548 | |
|
546 | 549 | def test_whole_cell(self): |
|
547 | 550 | src = "%%cellm line\nbody\n" |
|
548 | sp = self.sp | |
|
549 | sp.push(src) | |
|
550 | out = sp.source_reset() | |
|
551 | out = self.sp.transform_cell(src) | |
|
551 | 552 | ref = u"get_ipython().run_cell_magic({u}'cellm', {u}'line', {u}'body')\n" |
|
552 | 553 | nt.assert_equal(out, py3compat.u_format(ref)) |
|
553 | 554 |
@@ -204,10 +204,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
204 | 204 | prompt created. When triggered by an Enter/Return key press, |
|
205 | 205 | 'interactive' is True; otherwise, it is False. |
|
206 | 206 | """ |
|
207 | try: | |
|
208 | self._input_splitter.reset() | |
|
209 | except SyntaxError: | |
|
210 | pass | |
|
207 | self._input_splitter.reset() | |
|
211 | 208 | try: |
|
212 | 209 | complete = self._input_splitter.push(source) |
|
213 | 210 | except SyntaxError: |
@@ -239,10 +236,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
239 | 236 | """ |
|
240 | 237 | # Flush all state from the input splitter so the next round of |
|
241 | 238 | # reading input starts with a clean buffer. |
|
242 | try: | |
|
243 | self._input_splitter.reset() | |
|
244 | except SyntaxError: | |
|
245 | pass | |
|
239 | self._input_splitter.reset() | |
|
246 | 240 | |
|
247 | 241 | if not self._reading: |
|
248 | 242 | self._highlighter.highlighting_on = False |
@@ -258,7 +258,7 b' class EmbeddedSphinxShell(object):' | |||
|
258 | 258 | splitter.push(line) |
|
259 | 259 | more = splitter.push_accepts_more() |
|
260 | 260 | if not more: |
|
261 |
source_raw = splitter. |
|
|
261 | source_raw = splitter.raw_reset() | |
|
262 | 262 | self.IP.run_cell(source_raw, store_history=store_history) |
|
263 | 263 | finally: |
|
264 | 264 | sys.stdout = stdout |
@@ -455,7 +455,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):' | |||
|
455 | 455 | #double-guard against keyboardinterrupts during kbdint handling |
|
456 | 456 | try: |
|
457 | 457 | self.write('\nKeyboardInterrupt\n') |
|
458 |
source_raw = self.input_splitter. |
|
|
458 | source_raw = self.input_splitter.raw_reset() | |
|
459 | 459 | hlen_b4_cell = self._replace_rlhist_multiline(source_raw, hlen_b4_cell) |
|
460 | 460 | more = False |
|
461 | 461 | except KeyboardInterrupt: |
@@ -483,7 +483,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):' | |||
|
483 | 483 | self.autoedit_syntax): |
|
484 | 484 | self.edit_syntax_error() |
|
485 | 485 | if not more: |
|
486 |
source_raw = self.input_splitter. |
|
|
486 | source_raw = self.input_splitter.raw_reset() | |
|
487 | 487 | hlen_b4_cell = self._replace_rlhist_multiline(source_raw, hlen_b4_cell) |
|
488 | 488 | self.run_cell(source_raw) |
|
489 | 489 |
@@ -518,7 +518,7 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
518 | 518 | #double-guard against keyboardinterrupts during kbdint handling |
|
519 | 519 | try: |
|
520 | 520 | self.write('\nKeyboardInterrupt\n') |
|
521 |
source_raw = self.input_splitter. |
|
|
521 | source_raw = self.input_splitter.raw_reset() | |
|
522 | 522 | hlen_b4_cell = \ |
|
523 | 523 | self._replace_rlhist_multiline(source_raw, hlen_b4_cell) |
|
524 | 524 | more = False |
@@ -552,7 +552,7 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
552 | 552 | self.autoedit_syntax): |
|
553 | 553 | self.edit_syntax_error() |
|
554 | 554 | if not more: |
|
555 |
source_raw = self.input_splitter. |
|
|
555 | source_raw = self.input_splitter.raw_reset() | |
|
556 | 556 | self.run_cell(source_raw, store_history=True) |
|
557 | 557 | hlen_b4_cell = \ |
|
558 | 558 | self._replace_rlhist_multiline(source_raw, hlen_b4_cell) |
General Comments 0
You need to be logged in to leave comments.
Login now