From 9281c5bf67aab6b4ff68875caa6c6ad1d7512017 2011-10-14 23:33:28 From: Thomas Kluyver Date: 2011-10-14 23:33:28 Subject: [PATCH] Use run_cell for %paste, instead of plain exec. Closes gh-865, but introduces test failures for %cpaste --- diff --git a/IPython/core/magic.py b/IPython/core/magic.py index 32ec4b0..ba2d2e1 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -3246,7 +3246,7 @@ Defaulting color scheme to 'NoColor'""" if not par: b = textwrap.dedent(block) self.user_ns['pasted_block'] = b - exec b in self.user_ns + self.run_cell(b) else: self.user_ns[par] = SList(block.splitlines()) print "Block assigned to '%s'" % par diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index fe82b86..afba614 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -316,6 +316,7 @@ def check_cpaste(code, should_fail=False): _ip.user_ns['code_ran'] = False src = StringIO() + src.encoding = None # IPython expects stdin to have an encoding attribute src.write('\n') src.write(code) src.write('\n--\n')