Skip to content
This repository
Browse code

Use run_cell for %paste, instead of plain exec.

Closes gh-865, but introduces test failures for %cpaste
  • Loading branch information...
commit 9281c5bf67aab6b4ff68875caa6c6ad1d7512017 1 parent 3ac262c
Thomas Kluyver takluyver authored
2  IPython/core/magic.py
@@ -3246,7 +3246,7 @@ def _execute_block(self, block, par):
3246 3246 if not par:
3247 3247 b = textwrap.dedent(block)
3248 3248 self.user_ns['pasted_block'] = b
3249   - exec b in self.user_ns
  3249 + self.run_cell(b)
3250 3250 else:
3251 3251 self.user_ns[par] = SList(block.splitlines())
3252 3252 print "Block assigned to '%s'" % par
1  IPython/core/tests/test_magic.py
@@ -316,6 +316,7 @@ def check_cpaste(code, should_fail=False):
316 316 _ip.user_ns['code_ran'] = False
317 317
318 318 src = StringIO()
  319 + src.encoding = None # IPython expects stdin to have an encoding attribute
319 320 src.write('\n')
320 321 src.write(code)
321 322 src.write('\n--\n')

0 comments on commit 9281c5b

Please sign in to comment.
Something went wrong with that request. Please try again.