Title: argparse.ArgumentParser.parses_args does not honor exit_on_error=False when given unrecognized arguments · Issue #121018 · python/cpython · GitHub
Open Graph Title: argparse.ArgumentParser.parses_args does not honor exit_on_error=False when given unrecognized arguments · Issue #121018 · python/cpython
X Title: argparse.ArgumentParser.parses_args does not honor exit_on_error=False when given unrecognized arguments · Issue #121018 · python/cpython
Description: Bug report Bug description: As reported in Discourse, even though the documentation on the exit_on_error argument for argparse.ArgumentParser says: exit_on_error - Determines whether or not ArgumentParser exits with error info when an er...
Open Graph Description: Bug report Bug description: As reported in Discourse, even though the documentation on the exit_on_error argument for argparse.ArgumentParser says: exit_on_error - Determines whether or not Argumen...
X Description: Bug report Bug description: As reported in Discourse, even though the documentation on the exit_on_error argument for argparse.ArgumentParser says: exit_on_error - Determines whether or not Argumen...
Opengraph URL: https://github.com/python/cpython/issues/121018
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"argparse.ArgumentParser.parses_args does not honor exit_on_error=False when given unrecognized arguments","articleBody":"# Bug report\n\n### Bug description:\n\nAs reported in [Discourse](https://discuss.python.org/t/about-the-exit-on-error-setting-in-argparse/56702), even though the documentation on the `exit_on_error` argument for `argparse.ArgumentParser` says:\n\n\u003e [`exit_on_error`](https://docs.python.org/3/library/argparse.html#exit-on-error) - Determines whether or not `ArgumentParser` exits with error info when an error occurs. (default: `True`)\n\nThe `parse_args` method would still exit with error info when there are unrecognized arguments:\n```python\nimport argparse\nparser = argparse.ArgumentParser(exit_on_error=False)\ntry:\n parser.parse_args('invalid arguments'.split())\nexcept argparse.ArgumentError:\n print('ArgumentError caught.')\n```\nwhich outputs:\n```\nusage: test.py [-h]\ntest.py: error: unrecognized arguments: invalid arguments\n```\n\n### CPython versions tested on:\n\n3.12, CPython main branch\n\n### Operating systems tested on:\n\nLinux, Windows\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-121019\n* gh-121031\n* gh-121032\n* gh-121056\n* gh-121128\n* gh-121129\n* gh-121510\n* gh-121516\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/blhsing","@type":"Person","name":"blhsing"},"datePublished":"2024-06-26T03:01:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/121018/cpython/issues/121018"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b62d08e2-2a0c-1933-4ca0-d9e922ca6ef9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9610:27340E:195CC2:213B88:696B623C |
| html-safe-nonce | 42675dbb07a5237fa9c781d6a2f941ac3d6c60ae3d499f5e732a8206be7c89db |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjEwOjI3MzQwRToxOTVDQzI6MjEzQjg4OjY5NkI2MjNDIiwidmlzaXRvcl9pZCI6IjYxNzUzOTk0ODI4NTAyMzkwMzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 81204527dde91a4035cb23df8c1c6b79bac486fe9d7d5fdcb7bc35dc1ec5b629 |
| hovercard-subject-tag | issue:2374080325 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/121018/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fdf2b91029cddce1ed09d9cdc5167be79146e8a981b08e9efa576d549ad941dd/python/cpython/issues/121018 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fdf2b91029cddce1ed09d9cdc5167be79146e8a981b08e9efa576d549ad941dd/python/cpython/issues/121018 |
| og:image:alt | Bug report Bug description: As reported in Discourse, even though the documentation on the exit_on_error argument for argparse.ArgumentParser says: exit_on_error - Determines whether or not Argumen... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | blhsing |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width