[ python-Bugs-1436900 ] Problem parsing cmdline parameter quoted with a trailing \

SourceForge.net noreply at sourceforge.net
Wed Feb 22 21:38:05 CET 2006


Bugs item #1436900, was opened at 2006-02-22 18:38
Message generated for change (Comment added) made by splitscreen
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1436900&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Wai Yip Tung (tungwaiyip)
Assigned to: Nobody/Anonymous (nobody)
Summary: Problem parsing cmdline parameter quoted with a trailing \

Initial Comment:
This problem happens in launching Python from Windows. 
A quoted pathname is used as parameter. If and only if 
the pathname is ended with a trailing \, it is treated 
as an escape character.

p.py
-------------------------------------------------------
import sys
from pprint import pprint
pprint(sys.argv)
-------------------------------------------------------

Note slash inside the quote is treated as path 
separators

g:\usr\bin>c:\python24\python.exe  g:\usr\bin\p.py "
tung\wai\yip" wai
['g:\\usr\\bin\\p.py', 'tung\\wai\\yip', 'wai']


However the trailing \ is treated as an escape 
character for the quote. Only command line parameter 
is presented in sys.argv.

g:\usr\bin>c:\python24\python.exe  g:\usr\bin\p.py "
tung\wai\yip\" wai
['g:\\usr\\bin\\p.py', 'tung\\wai\\yip" wai']



----------------------------------------------------------------------

Comment By: splitscreen (splitscreen)
Date: 2006-02-22 20:38

Message:
Logged In: YES 
user_id=1126061

Whoops, my bad. Its a windows issue, not a python one.

----------------------------------------------------------------------

Comment By: splitscreen (splitscreen)
Date: 2006-02-22 20:34

Message:
Logged In: YES 
user_id=1126061

After having a quick look it appears as though python is in
fact stripping the trailing '\'. the argv array that the
python interpreter is passed contains the backslash so it
must be doing away with it.



----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2006-02-22 20:12

Message:
Logged In: YES 
user_id=849994

Is that Python-specific? I thought sys.argv is the cmdline
args as Python gets them from Windows.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1436900&group_id=5470


More information about the Python-bugs-list mailing list