René's URL Explorer Experiment


Title: argparse nargs=-1 fails on python 3.12.7 · Issue #126708 · python/cpython · GitHub

Open Graph Title: argparse nargs=-1 fails on python 3.12.7 · Issue #126708 · python/cpython

X Title: argparse nargs=-1 fails on python 3.12.7 · Issue #126708 · python/cpython

Description: Bug report Bug description: It seems there's a pattern in the wild with argparse where nargs=-1 is used to capture the remaining command line arguments. However, I couldn’t find anything in the argparse nargs documentation to indicate th...

Open Graph Description: Bug report Bug description: It seems there's a pattern in the wild with argparse where nargs=-1 is used to capture the remaining command line arguments. However, I couldn’t find anything in the arg...

X Description: Bug report Bug description: It seems there's a pattern in the wild with argparse where nargs=-1 is used to capture the remaining command line arguments. However, I couldn’t find anything in the...

Opengraph URL: https://github.com/python/cpython/issues/126708

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"argparse nargs=-1 fails on python 3.12.7","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nIt seems there's a pattern in the wild with `argparse` where `nargs=-1` is used to capture the remaining command line arguments. However, I couldn’t find anything in the [argparse nargs documentation](https://docs.python.org/3/library/argparse.html#nargs) to indicate that this is a supported feature, though it appears to be widely used: https://grep.app/search?current=4&q=nargs%3D-1&filter[lang][0]=Python\r\n\r\nThis pattern has stopped working as of Python `v3.12.7`,  likely due to #124631 which doesn't appear to have made it to v3.13.0,  but it has been backported to the `3.13` branch. \r\n\r\nTo reproduce, \r\n1. Create an `issue.py` file\r\n```python\r\nimport argparse\r\nimport sys\r\nprint(f\":version {sys.version}\")\r\nparser = argparse.ArgumentParser()\r\nparser.add_argument(\"args\", nargs=-1)\r\nparsed_args, extra = parser.parse_known_args()\r\nprint(f\":args {parsed_args} :extra {extra}\")\r\n```\r\n2. and run it with python 3.12.7, you should get a `the following arguments are required` error.\r\n```console\r\n$ d:/local/Python312/python.exe issue.py 5 6\r\nusage: issue.py [-h]\r\nissue.py: error: the following arguments are required: args\r\n:version 3.12.7 (tags/v3.12.7:0b05ead, Oct  1 2024, 03:06:41) [MSC v.1941 64 bit (AMD64)]\r\n```\r\n\r\nThe same works with any other version at the momenet, for example 3.11 or 3.13:\r\n```console\r\n$ python.exe issue.py 5 6\r\n:version 3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]\r\n:args Namespace(args=[]) :extra ['5', '6']\r\n\r\n$ d:/local/Python313/python.exe issue.py 5 6\r\n:version 3.13.0 (tags/v3.13.0:60403a5, Oct  7 2024, 09:38:07) [MSC v.1941 64 bit (AMD64)]\r\n:args Namespace(args=[]) :extra ['5', '6']\r\n```\r\n\r\nCould you please take a look and advise whether this is something you might want to continue supporting, or if there are alternative approaches you would recommend?\r\n\r\nI don't personally use this pattern, but I came across it and thought it would be helpful to report, as it might assist developers in making informed decisions about it.\r\n\r\nThanks\r\n\r\n### CPython versions tested on:\r\n\r\n3.12, CPython main branch\r\n\r\n### Operating systems tested on:\r\n\r\nWindows","author":{"url":"https://github.com/ikappaki","@type":"Person","name":"ikappaki"},"datePublished":"2024-11-11T23:03:35Z","url":"https://github.com/python/cpython/issues/126708"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:7faf646d-9a04-ee03-c5c2-3c2ca5509081
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEB74:283776:1003502:15787A0:6B005C73
html-safe-noncecf23a79c5028a2b93f4221d0f17e7fd91212b365364c571b4503d83793ff14fe
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjc0OjI4Mzc3NjoxMDAzNTAyOjE1Nzg3QTA6NkIwMDVDNzMiLCJ2aXNpdG9yX2lkIjoiMzczMjQ1NzQ2Njg1MjU2NDA4MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac2a81dbd67226c82db374963cbc00f3c20213560849fa49fc41d5a48d0fd6babb
hovercard-subject-tagissue:2650599822
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/126708/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4f24166f03e28595cd764ca387edee3b77a4640e89774eba5cae6493a061914f/python/cpython/issues/126708
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4f24166f03e28595cd764ca387edee3b77a4640e89774eba5cae6493a061914f/python/cpython/issues/126708
og:image:altBug report Bug description: It seems there's a pattern in the wild with argparse where nargs=-1 is used to capture the remaining command line arguments. However, I couldn’t find anything in the arg...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameikappaki
hostnamegithub.com
expected-hostnamegithub.com
None29be975efff6507a5d135de9c7d634cf7ff8f0c55222a64386ab3202209aaf73
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseeacd927ba6112e3b01ba99c762bd699a4a4f5df7
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/126708#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F126708
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F126708
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/126708
Reloadhttps://github.com/python/cpython/issues/126708
Reloadhttps://github.com/python/cpython/issues/126708
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/126708
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/126708
argparse nargs=-1 fails on python 3.12.7https://github.com/python/cpython/issues/126708#top
pendingThe issue will be closed if no feedback is providedhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22pending%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/ikappaki
ikappakihttps://github.com/ikappaki
on Nov 11, 2024https://github.com/python/cpython/issues/126708#issue-2650599822
argparse nargs documentationhttps://docs.python.org/3/library/argparse.html#nargs
https://grep.app/search?current=4&q=nargs%3D-1&filter[lang][0]=Pythonhttps://grep.app/search?current=4&q=nargs%3D-1&filter%5Blang%5D%5B0%5D=Python
#124631https://github.com/python/cpython/pull/124631
ikappakihttps://github.com/ikappaki
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Nov 11, 2024https://github.com/python/cpython/issues/126708#event-15256414788
https://github.com/brianschubert
brianschuberthttps://github.com/brianschubert
on Nov 11, 2024https://github.com/python/cpython/issues/126708#issuecomment-2469299411
https://grep.app/search?q=add_argument%5C%28%5B%5E%29%5D%2Bnargs%3D-1®exp=true&filter%5Blang%5D%5B0%5D=Pythonhttps://grep.app/search?q=add_argument%5C%28%5B%5E%29%5D%2Bnargs%3D-1®exp=true&filter%5Blang%5D%5B0%5D=Python
hugovkhttps://github.com/hugovk
Argparse issueshttps://github.com/orgs/python/projects/5
on Nov 12, 2024https://github.com/python/cpython/issues/126708#event-15261875649
https://github.com/hugovk
hugovkhttps://github.com/hugovk
on Nov 12, 2024https://github.com/python/cpython/issues/126708#issuecomment-2470112386
@serhiy-storchakahttps://github.com/serhiy-storchaka
@savannahostrowskihttps://github.com/savannahostrowski
https://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on Nov 12, 2024https://github.com/python/cpython/issues/126708#issuecomment-2470364157
@brianschuberthttps://github.com/brianschubert
https://github.com/chrisrink10
chrisrink10https://github.com/chrisrink10
on Nov 12, 2024https://github.com/python/cpython/issues/126708#issuecomment-2470561573
https://grep.app/search?q=add_argument%5C%28%5B%5E%29%5D%2Bnargs%3D-1®exp=true&filter%5Blang%5D%5B0%5D=Pythonhttps://grep.app/search?q=add_argument%5C%28%5B%5E%29%5D%2Bnargs%3D-1®exp=true&filter%5Blang%5D%5B0%5D=Python
@brianschuberthttps://github.com/brianschubert
I incorrectly translated over to argparse after removing Clickhttps://github.com/basilisp-lang/basilisp/commit/939549f8ae73272fa80fb05f0e8ffaea3923596d#diff-6793ba1632ae6b66a95181cb783d8df4fde5ec60634b56c61d00490cbe9a5ad2L245
@serhiy-storchakahttps://github.com/serhiy-storchaka
@ikappakihttps://github.com/ikappaki
picnixzhttps://github.com/picnixz
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
pendingThe issue will be closed if no feedback is providedhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22pending%22
on Nov 12, 2024https://github.com/python/cpython/issues/126708#event-15265599787
https://github.com/ikappaki
ikappakihttps://github.com/ikappaki
on Nov 12, 2024https://github.com/python/cpython/issues/126708#issuecomment-2471314553
similarity https://click.palletsprojects.com/en/stable/why/#why-not-argparse
hugovkhttps://github.com/hugovk
not plannedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Anot-planned
on Nov 12, 2024https://github.com/python/cpython/issues/126708#event-15270420742
github-project-automationhttps://github.com/apps/github-project-automation
Argparse issueshttps://github.com/orgs/python/projects/5
on Nov 12, 2024https://github.com/python/cpython/issues/126708
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/126708
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/126708
pendingThe issue will be closed if no feedback is providedhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22pending%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
Argparse issueshttps://github.com/orgs/python/projects/5
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.