From 0407756fdb3f974e917f31d4793958d572c49fb9 2013-01-05 15:52:49 From: mr.Shu Date: 2013-01-05 15:52:49 Subject: [PATCH] Added try/finally block to set using_paste_magics --- diff --git a/IPython/frontend/terminal/interactiveshell.py b/IPython/frontend/terminal/interactiveshell.py index b9a5ef4..252d4ec 100644 --- a/IPython/frontend/terminal/interactiveshell.py +++ b/IPython/frontend/terminal/interactiveshell.py @@ -159,8 +159,10 @@ class TerminalMagics(Magics): else: self.shell.user_ns['pasted_block'] = b self.shell.using_paste_magics = True - self.shell.run_cell(b) - self.shell.using_paste_magics = True + try: + self.shell.run_cell(b) + finally: + self.shell.using_paste_magics = False def rerun_pasted(self, name='pasted_block'): """ Rerun a previously pasted command.