[New-bugs-announce] [issue45580] argparse.ArgumentParser.add_mutually_exclusive_group : metavar create parenthesis undefined behavior
AbcSxyZ
report at bugs.python.org
Fri Oct 22 15:31:30 EDT 2021
New submission from AbcSxyZ <rossi.sim at outlook.com>:
Hi,
I'm getting a kind of undefined behavior where parenthesis seem handled in a strange way. On display, it has a conflict between parenthesis of the option, and nested parenthesis within a metavar.
## Reproduction script
```
import argparse
def main():
parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("-p", "--path", metavar="/var/www/html",
help="DocumentRoot path")
group.add_argument("-r", "--reverse", metavar="http)s(://Host:Port",
help="Reverse proxy address")
parser.add_argument("--last-args")
return parser.parse_args()
main()
```
## Output of help menu
```
usage: crash.py [-h] (-p /var/www/html | -r http)s://Host:Port [--last-args LAST_ARGS]
```
## Expected behavior
```
usage: crash.py [-h] (-p /var/www/html | -r http)s(://Host:Port) [--last-args LAST_ARGS]
```
----------
components: Parser
messages: 404815
nosy: AbcSxyZ, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: argparse.ArgumentParser.add_mutually_exclusive_group : metavar create parenthesis undefined behavior
versions: Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45580>
_______________________________________
More information about the New-bugs-announce
mailing list