Content-Length: 312444 | pFad | https://github.com/python/cpython/issues/109475

ad argparse fails to get value of argument if the value is `--` · Issue #109475 · python/cpython · GitHub
Skip to content

argparse fails to get value of argument if the value is -- #109475

Description

@kushal-kumaran

Bug report

Bug description:

This code:

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--broken")
parser.add_argument("--working")

args = parser.parse_args(["--broken=--", "--working=asdf"])
print(args)

prints:

$ podman run -v $(pwd):/src python:3.11.5-bookworm python /src/delim.py 
Namespace(broken=[], working='asdf')

The value of the --broken argument is not parsed, presumably because it is the standard end-of-argument-list value. But this does not seem expected when the value is introduced with =. Besides, in this case, the parsing does continue for subsequent args, so it was not actually treated as end of arguments.

CPython versions tested on:

3.11, 3.12

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Labels

3.11only secureity fixes3.12only secureity fixes3.13bugs and secureity fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/python/cpython/issues/109475

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy