Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix up magic_edit functions so they work again.

  • Loading branch information...
commit f332431ef2e26155a092fc68a39bfa94fc41c9e0 1 parent 1a4f06e
@takluyver authored
Showing with 10 additions and 7 deletions.
  1. +4 −5 IPython/core/magic.py
  2. +6 −2 IPython/zmq/zmqshell.py
View
9 IPython/core/magic.py
@@ -2245,7 +2245,7 @@ class DataIsObject(Exception): pass
filename = self.shell.mktempfile(data)
print 'IPython will make a temporary file named:',filename
- return filename
+ return filename, lineno, use_temp
def _edit_macro(self,mname,macro):
"""open an editor with the macro data in a file"""
@@ -2407,7 +2407,7 @@ def magic_edit(self,parameter_s='',last_call=['','']):
opts,args = self.parse_options(parameter_s,'prxn:')
try:
- filename = self._find_edit_target(args, opts, last_call)
+ filename, lineno, is_temp = self._find_edit_target(args, opts, last_call)
except MacroToEdit as e:
self._edit_macro(args, e.args[0])
return
@@ -2433,15 +2433,14 @@ def magic_edit(self,parameter_s='',last_call=['','']):
print
else:
print 'done. Executing edited code...'
- if opts_raw:
+ if 'r' in opts: # Untranslated IPython code
self.shell.run_cell(file_read(filename),
store_history=False)
else:
self.shell.safe_execfile(filename,self.shell.user_ns,
self.shell.user_ns)
-
- if use_temp:
+ if is_temp:
try:
return open(filename).read()
except IOError,msg:
View
8 IPython/zmq/zmqshell.py
@@ -29,6 +29,7 @@
from IPython.core.displayhook import DisplayHook
from IPython.core.displaypub import DisplayPublisher
from IPython.core.macro import Macro
+from IPython.core.magic import MacroToEdit
from IPython.core.payloadpage import install_payload_page
from IPython.utils import io
from IPython.utils.path import get_py_filename
@@ -398,11 +399,14 @@ def magic_edit(self,parameter_s='',last_call=['','']):
starting example for further modifications. That file also has
general instructions on how to set a new hook for use once you've
defined it."""
+
+ opts,args = self.parse_options(parameter_s,'prn:')
+
try:
- filename = self._find_edit_target(args, opts, last_call)
+ filename, lineno, _ = self._find_edit_target(args, opts, last_call)
except MacroToEdit as e:
# TODO: Implement macro editing over 2 processes.
- print "Macro editing not yet implemented in 2-process model."
+ print("Macro editing not yet implemented in 2-process model.")
return
# Make sure we send to the client an absolute path, in case the working
Please sign in to comment.
Something went wrong with that request. Please try again.