Browse files

Support relative import in "%run -m"

  • Loading branch information...
1 parent f97338d commit 41039016e97c1a1297215c277625ca9b3f494893 @tkf committed Mar 23, 2013
Showing with 12 additions and 8 deletions.
  1. +12 −8 IPython/core/magics/execution.py
View
20 IPython/core/magics/execution.py
@@ -593,14 +593,18 @@ def run(self, parameter_s='', runner=None,
# user (run by exec in pdb itself).
self.shell.InteractiveTB(etype, value, tb, tb_offset=3)
else:
- if runner is None:
- runner = self.default_runner
- if runner is None:
- runner = self.shell.safe_execfile
-
- def run():
- runner(filename, prog_ns, prog_ns,
- exit_ignore=exit_ignore)
+ if 'm' in opts:
+ def run():
+ self.shell.safe_run_module(modulename, prog_ns)
+ else:
+ if runner is None:
+ runner = self.default_runner
+ if runner is None:
+ runner = self.shell.safe_execfile
+
+ def run():
+ runner(filename, prog_ns, prog_ns,
+ exit_ignore=exit_ignore)
if 't' in opts:
# timed execution

0 comments on commit 4103901

Please sign in to comment.