diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index 1abe45d..3c820ff 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -593,14 +593,18 @@ python-profiler package from non-free.""") # 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