Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleaner fix for qt execute_file bug:

Possible because double quotes can be escaped in double quotes (unlike single in single) in posix.
  • Loading branch information...
commit 5f0d4ada0468cf72f46a7c1464d271db77774321 1 parent ebfa946
Jonathan March authored
Showing with 7 additions and 12 deletions.
  1. +7 −12 IPython/frontend/qt/console/ipython_widget.py
19 IPython/frontend/qt/console/ipython_widget.py
View
@@ -277,18 +277,13 @@ def execute_file(self, path, hidden=False):
# Perhaps we should not be using %run directly, but while we
# are, it is necessary to quote or escape filenames containing spaces
- # or quotes. As much as possible, we quote: more readable than escape.
- if '"' in path:
- if "'" in path:
- # In this case, because %run 'a\'b"c.py' fails, we must escape
- # all quotes and spaces.
- for c in '" \'':
- path = path.replace(c, '\\'+c)
- else:
- path = "'%s'" % path
- elif ' ' in path or "'" in path:
- path = '"%s"' % path
-
+ # or quotes. Note that in this context, because run uses posix
+ # parsing, we can escape double quotes in a double quoted filename,
+ # but can't escape singe quotes in a single quoted filename.
+ if "'" in path:
+ path = '"%s"' % path.replace('"', '\\"')
+ elif ' ' in path or '"' in path:
+ path = "'%s'" % path
self.execute('%%run %s' % path, hidden=hidden)
#---------------------------------------------------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.