8000 Argparse misparses options in certain situations · Issue #94843 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Argparse misparses options in certain situations #94843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DemiMarie opened this issue Jul 14, 2022 · 2 comments
Closed

Argparse misparses options in certain situations #94843

DemiMarie opened this issue Jul 14, 2022 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@DemiMarie
Copy link
DemiMarie commented Jul 14, 2022

Bug report

The argparse module misparses options in certain complex situations. I am not sure what the exact prerequisites are, but Qubes OS does manage to trigger the issue. QubesOS/qubes-core-admin-client#214 has the details. Sorry for the lack of a minimal reproducer.

Edit: One case where the bug happens is when an option X (which takes an optional argument) is followed by an optional positional parameter, and the two are mutually exclusive. Argparse thinks that --dispvm A B C is --dispvm=A -- B C and considers B to be the optional positional parameter. Since it is mutually incompatible with --dispvm, an exception is thrown.

Your environment

  • CPython versions tested on: 3.8 through 3.10 inclusive
  • Operating system and architecture: Linux x86_64
@DemiMarie DemiMarie added the type-bug An unexpected behavior, bug, or error label Jul 14, 2022
@AlexWaygood AlexWaygood added the stdlib Python modules in the Lib dir label Jul 14, 2022
@terryjreedy terryjreedy moved this to Bugs in Argparse issues Aug 16, 2023
@serhiy-storchaka
Copy link
Member

If I understand this correctly, the original issue was fixed in #81691 and #53780.

The case mentioned in the second paragraph seems unrelated to the bug and is a new feature request. Please open a new issue if you still want it to be implemented. Please be more concrete in the title and provide more details of expected behavior, preferably with a sample code.

@serhiy-storchaka serhiy-storchaka added the pending The issue will be closed if no feedback is provided label Oct 22, 2024
@picnixz
Copy link
Member
picnixz commented Dec 2, 2024

Closing as completed since the original issue was fixed. A new issue could be opened as Serhiy suggested for a new feature request.

@picnixz picnixz closed this as completed Dec 2, 2024
@github-project-automation github-project-automation bot moved this from Bugs to Doc issues in Argparse issues Dec 2, 2024
@picnixz picnixz removed the pending The issue will be closed if no feedback is provided label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
Status: Doc issues
Development

No branches or pull requests

4 participants
0