Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug in argument parsing for %run #592

Closed
jstenar opened this Issue · 4 comments

3 participants

Jörgen Stenarson Fernando Perez Thomas Kluyver
Jörgen Stenarson
Collaborator

Excerpt from discussion on ipython-dev:

This problem is with master 9e2a3f4, calling %run with parameters that have quotation marks keep the marks in sys.argv.

runbug.py:

import sys
sys.argv

In [2]: %run runbug.py "hello world"
[u'runbug.py', u'"hello world"']

This is unique to Windows, somehow.

As far as I can tell it is due to shlex that is called from arg_split. When on posix shlex is called with posix=True which removes the quotation marks, but on windows we get posix=False which keeps them. If we call shlex with posix=True on windows we get messed up handling of \ in paths since posix means \ is used for escaping.

Perhaps one solution could be to strip " from elements returned by arg_split when they are present in both ends, any other ideas?

It is really annoying to not be able to use " from run, unfortunately there are often spaces in windows paths.

/Jörgen

Jörgen Stenarson jstenar referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Jörgen Stenarson
Collaborator

In my arg_parse branch I have a first stab at a fix. I will try to use this myself for a while to see if any unforseen issues come up. Then I'll write some tests.

/Jörgen

Fernando Perez
Owner

@jstenar, has this been fixed? I'd like to close it if so. If not, do you have your branch around with the fixes, so we can merge it? Thanks!

Jörgen Stenarson
Collaborator

I do not remember when, but a simple fix for this has gone in already. However quoting only works on the first argument to %run and not for arbitrary arguments.

Running a script that prints argv:

In [1]: %run "space test.py" "testing quoted arguments"
['space test.py', '"testing quoted arguments"']
Jörgen Stenarson jstenar referenced this issue
Merged

Win32 shlex #1064

Thomas Kluyver
Owner

Closed by PR #1064.

Thomas Kluyver takluyver closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.