Issue36863
Created on 2019-05-09 08:39 by rhubarbdog x, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| command.py | rhubarbdog x, 2019-05-12 01:44 | |||
| Messages (5) | |||
|---|---|---|---|
| msg341973 - (view) | Author: rhubarbdog x (rhubarbdog x) | Date: 2019-05-09 08:39 | |
I've found a bug with argparse and reported it upstream. `command --option source destination` works `command soucre destination --option` works but `command source --option destination` doesn't outputting the usage text block associated `do_command` method and outputs error message `command: error: unrecognized arguments: destination` |
|||
| msg341974 - (view) | Author: rhubarbdog x (rhubarbdog x) | Date: 2019-05-09 08:43 | |
This is when running is a shell which inherits from cmd.Cmd |
|||
| msg342160 - (view) | Author: Martin Panter (martin.panter) * ![]() |
Date: 2019-05-11 05:34 | |
The “cmd” module doesn’t use “argparse” as far as I can see. You might have to provide more information or code for someone to make sense of or reproduce your bug. Also, see Issue 14191 which added new “parse_[known]_intermixed_args” APIs in 3.7, and have a look at Issue 15112, about intermixing options between particular kinds of positional parameters. |
|||
| msg342234 - (view) | Author: rhubarbdog x (rhubarbdog x) | Date: 2019-05-12 01:44 | |
I've just done a test and from a command shell (bash or whatever) the following python script when ran produces the following $ python3 command.py 0ne thwo three files: ['0ne', 'thwo', 'three'] sensors 1 freq 1200 $ python3 command.py -s 5 0ne thwo three files: ['0ne', 'thwo', 'three'] sensors 5 freq 1200 $ python3 command.py 0ne -s 5 thwo three usage: command.py [-h] [-s SENSORS] [-f FREQ] file [file ...] command.py: error: unrecognized arguments: thwo three i've attached the program command.py |
|||
| msg343683 - (view) | Author: paul j3 (paul.j3) * ![]() |
Date: 2019-05-27 20:14 | |
This is intended behavior of multi-nargs positionals. The 'one' string is consumed by the 'file' argument, and there's no positional argument left to consume the other strings. The topic was raised and discussed previously https://bugs.python.org/issue14191 -argparse doesn't allow optionals within positionals The fix is to use 'parser.parse_intermixed_args()', as documented in https://docs.python.org/3/library/argparse.html#intermixed-parsing |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:14 | admin | set | github: 81044 |
| 2019-05-27 20:14:23 | paul.j3 | set | status: open -> closed nosy:
+ paul.j3 resolution: duplicate |
| 2019-05-12 01:44:35 | rhubarbdog x | set | files:
+ command.py status: pending -> open messages: + msg342234 |
| 2019-05-11 05:34:34 | martin.panter | set | status: open -> pending nosy: + martin.panter messages: + msg342160 |
| 2019-05-10 19:42:56 | v+python | set | nosy:
+ v+python |
| 2019-05-09 11:59:45 | larry | set | nosy:
- larry |
| 2019-05-09 08:43:27 | rhubarbdog x | set | messages: + msg341974 |
| 2019-05-09 08:40:26 | SilentGhost | set | stage: test needed type: behavior components: + Library (Lib), - Argument Clinic versions: + Python 3.7, Python 3.8 |
| 2019-05-09 08:39:22 | rhubarbdog x | create | |

