[issue41600] Expected behavior of argparse given quoted strings

2020-08-20 Thread Vegard Stikbakke
Vegard Stikbakke added the comment: Great idea, thanks! It's open source, so I'll see if I can fix it. On Thu, 20 Aug 2020 at 17:28, Eric V. Smith wrote: > > > Eric V. Smith added the comment: > > > > Completely agree with paul j3. The calling tool is breaking the "argv" > conventions. If t

[issue41600] Expected behavior of argparse given quoted strings

2020-08-20 Thread Eric V. Smith
Eric V. Smith added the comment: Completely agree with paul j3. The calling tool is breaking the "argv" conventions. If the OP can control the calling tool, it should be fixed there. -- ___ Python tracker _

[issue41600] Expected behavior of argparse given quoted strings

2020-08-20 Thread paul j3
paul j3 added the comment: I'd say the problem is with the deployment tool. Inputs like that should be split regardless of who's doing the commandline parsing. With normal shell input, quotes are used to prevent splitting, or to otherwise prevent substitutions and special character handlin

[issue41600] Expected behavior of argparse given quoted strings

2020-08-20 Thread Eric V. Smith
Change by Eric V. Smith : -- resolution: -> not a bug stage: -> resolved status: open -> closed type: enhancement -> behavior ___ Python tracker ___ _

[issue41600] Expected behavior of argparse given quoted strings

2020-08-20 Thread Vegard Stikbakke
Vegard Stikbakke added the comment: I see! Thanks, had not heard about shlex. I also had not realized `parse_args` takes arguments. Doh. That makes sense. Thanks a lot! -- ___ Python tracker __

[issue41600] Expected behavior of argparse given quoted strings

2020-08-20 Thread Eric V. Smith
Eric V. Smith added the comment: This is all working as designed. We do not want to modify argparse to split parameters. You probably want to split the input with shlex.split(). See https://stackoverflow.com/questions/44945815/how-to-split-a-string-into-command-line-arguments-like-the-shell-

[issue41600] Expected behavior of argparse given quoted strings

2020-08-20 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +paul.j3, rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscr

[issue41600] Expected behavior of argparse given quoted strings

2020-08-20 Thread Vegard Stikbakke
Vegard Stikbakke added the comment: In fact, what happens in the latter case (i.e. `"--a 1 --b 2"`), inside the call to `_parse_optional`, is that it fails to get the optional tuple. And so it continues to this line in argparse.py: https://github.com/python/cpython/blob/2ce39631f679e14132a54

[issue41600] Expected behavior of argparse given quoted strings

2020-08-20 Thread Vegard Stikbakke
Vegard Stikbakke added the comment: It seems that I mixed up something in the post here. If the quoted string is `"--a=1 --b=2` as I said in the post, then the program will only complain about `b` missing. In this case, it sets `a` to be `1 --b=2`. Whereas if the quoted string is `"--a 1 --b

[issue41600] Expected behavior of argparse given quoted strings

2020-08-20 Thread Vegard Stikbakke
Vegard Stikbakke added the comment: For what it's worth, I'd love to work on this if it's something that could be nice to have. -- ___ Python tracker ___

[issue41600] Expected behavior of argparse given quoted strings

2020-08-20 Thread Vegard Stikbakke
New submission from Vegard Stikbakke : I'm not sure if this is a bug, but I had a problem when I was trying to use argparse recently, and I was wondering about the expected behavior. For context: We invoke a Python program from a deployment tool, where we provide input in a text box. We were