Permalink
Browse files

Use run_cell for %paste, instead of plain exec.

Closes gh-865, but introduces test failures for %cpaste
  • Loading branch information...
1 parent 3ac262c commit 9281c5bf67aab6b4ff68875caa6c6ad1d7512017 @takluyver takluyver committed Oct 14, 2011
Showing with 2 additions and 1 deletion.
  1. +1 −1 IPython/core/magic.py
  2. +1 −0 IPython/core/tests/test_magic.py
View
2 IPython/core/magic.py
@@ -3246,7 +3246,7 @@ def _execute_block(self, block, par):
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
View
1 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')

0 comments on commit 9281c5b

Please sign in to comment.