##// END OF EJS Templates
BUG: execute_file fix failed on Windows....
Jonathan March -
Show More
@@ -277,13 +277,21 class IPythonWidget(FrontendWidget):
277 277
278 278 # Perhaps we should not be using %run directly, but while we
279 279 # are, it is necessary to quote or escape filenames containing spaces
280 # or quotes. Note that in this context, because run uses posix
281 # parsing, we can escape double quotes in a double quoted filename,
282 # but can't escape singe quotes in a single quoted filename.
283 if "'" in path:
280 # or quotes.
281
282 # In earlier code here, to minimize escaping, we sometimes quoted the
283 # filename with single quotes. But to do this, this code must be
284 # platform-aware, because run uses shlex rather than python string
285 # parsing, so that:
286 # * In Win: single quotes can be used in the filename without quoting,
287 # and we cannot use single quotes to quote the filename.
288 # * In *nix: we can escape double quotes in a double quoted filename,
289 # but can't escape single quotes in a single quoted filename.
290
291 # So to keep this code non-platform-specific and simple, we now only
292 # use double quotes to quote filenames, and escape when needed:
293 if ' ' in path or "'" in path or '"' in path:
284 294 path = '"%s"' % path.replace('"', '\\"')
285 elif ' ' in path or '"' in path:
286 path = "'%s'" % path
287 295 self.execute('%%run %s' % path, hidden=hidden)
288 296
289 297 #---------------------------------------------------------------------------
General Comments 0
You need to be logged in to leave comments. Login now