diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index 2ee2291..2383379 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -646,7 +646,9 @@ python-profiler package from non-free.""") return arg_lst = [modpath] + arg_lst try: - filename = file_finder(arg_lst[0]) + fpath = None # initialize to make sure fpath is in scope later + fpath = arg_lst[0] + filename = file_finder(fpath) except IndexError: warn('you must provide at least a filename.') print('\n%run:\n', oinspect.getdoc(self.run)) @@ -656,6 +658,9 @@ python-profiler package from non-free.""") msg = str(e) except UnicodeError: msg = e.message + import re + if os.name == 'nt' and re.match(r"^'.*'$",fpath): + warn('For Windows, use double quotes to wrap a filename: %run "mypath\\myfile.py"') error(msg) return