[New-bugs-announce] [issue19430] argparse replaces \$ to is passed

telmich report at bugs.python.org
Tue Oct 29 10:43:13 CET 2013


New submission from telmich:

When using argparse and the string \$ occurs on the commandline, it is converted to $. This as definitely wrong and renders argparse useless, if the input needs to be trusted (i.e. defitinely the same as given into it)'

Example code:

import sys 
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('test', nargs='*')
result = parser.parse_args(sys.argv[1:])

print("args = %s" % " ".join(sys.argv))
print("result = %s" % result)

Reproduce problem:

[10:41] bento:~% python3 argparse-test.py ps1  "PS1='[\t] \[\033[1m\]\h\[\033[0m\]:\w\$ '"
] \[\]\h\[\]:\w\$ '"args = argparse-test.py ps1 PS1='[\t] \[\033[1m\]\h\[\033[0m\]:\w$ '
result = Namespace(test=['ps1', "PS1='[\\t] \\[\\033[1m\\]\\h\\[\\033[0m\\]:\\w$ '"])

[10:40] bento:cdist% python --version
Python 3.3.2

----------
components: Library (Lib)
messages: 201614
nosy: telmich
priority: normal
severity: normal
status: open
title: argparse replaces  \$ to is passed
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19430>
_______________________________________


More information about the New-bugs-announce mailing list