Title: The error messages of `def func(*args='Hello'): pass` and `def func(**kwargs='Hello'): pass` should explain more clearly · Issue #137786 · python/cpython · GitHub
Open Graph Title: The error messages of `def func(*args='Hello'): pass` and `def func(**kwargs='Hello'): pass` should explain more clearly · Issue #137786 · python/cpython
X Title: The error messages of `def func(*args='Hello'): pass` and `def func(**kwargs='Hello'): pass` should explain more clearly · Issue #137786 · python/cpython
Description: Bug report Bug description: *args and **kwargs have an empty tuple and dictionary respectively as default values as shown below: def func(*args): print(args, type(args)) func() # ()
Open Graph Description: Bug report Bug description: *args and **kwargs have an empty tuple and dictionary respectively as default values as shown below: def func(*args): print(args, type(args)) func() # ()
X Description: Bug report Bug description: *args and **kwargs have an empty tuple and dictionary respectively as default values as shown below: def func(*args): print(args, type(args)) func() # () <class '...
Opengraph URL: https://github.com/python/cpython/issues/137786
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"The error messages of `def func(*args='Hello'): pass` and `def func(**kwargs='Hello'): pass` should explain more clearly","articleBody":"# Bug report\n\n### Bug description:\n\n`*args` and `**kwargs` have an empty tuple and dictionary respectively as default values as shown below:\n\n```python\ndef func(*args):\n print(args, type(args))\n\nfunc()\n# () \u003cclass 'tuple'\u003e\n```\n\n```python\ndef func(**kwargs):\n print(kwargs, type(kwargs))\n\nfunc()\n{} \u003cclass 'dict'\u003e\n```\n\nThen, setting a default value to `*args` and `**kwargs` gets the error messages as shown below. I think the error messages should explain more clearly because Python doc doesn't explain `*args` and `**kwargs` are the optional parameters which have the immutable default values `()` and `{}` respectively and `var-keyword argument` and `var-keyword argument` should be `var-keyword parameter` and `var-keyword parameter`:\n\n```python\ndef func(*args='Hello'):\n pass\n# Error\n```\n\n\u003e SyntaxError: var-positional argument cannot have default value\n\n```python\ndef func(**kwargs='Hello'):\n pass\n# Error\n```\n\n\u003e SyntaxError: var-keyword argument cannot have default value\n\nSo, the error messages should be like belolw:\n\n\u003e SyntaxError: var-positional parameter's default value cannot be changed because it has the immutable default value `()`\n\n\u003e SyntaxError: var-keyword parameter's default value cannot be changed because it has the immutable default value `{}`\n\n### CPython versions tested on:\n\n3.12\n\n### Operating systems tested on:\n\nWindows\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-137793\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/hyperkai","@type":"Person","name":"hyperkai"},"datePublished":"2025-08-14T22:23:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/137786/cpython/issues/137786"}
| 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:3a9e1f97-200c-c053-1739-dda0b2fa26bc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D79E:11811:4B3B21:62F901:6A5BFCDE |
| html-safe-nonce | 1cda3aeae4eae055df1e20f1faf8f351169c69c32caa3f3d4535fefc6ad45cbc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzlFOjExODExOjRCM0IyMTo2MkY5MDE6NkE1QkZDREUiLCJ2aXNpdG9yX2lkIjoiODc1MTk2MzM2Nzc3NzIzMTAyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 998f34928e3ad1096c4b7f22c7cd6f0cb357f1d1ccc6801a55678d6f667589d8 |
| hovercard-subject-tag | issue:3323751159 |
| 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/137786/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f498bf437a2aff04aa75b582cf4d9c225cce6ca231360c631f0a6a654a02fa24/python/cpython/issues/137786 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f498bf437a2aff04aa75b582cf4d9c225cce6ca231360c631f0a6a654a02fa24/python/cpython/issues/137786 |
| og:image:alt | Bug report Bug description: *args and **kwargs have an empty tuple and dictionary respectively as default values as shown below: def func(*args): print(args, type(args)) func() # () |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hyperkai |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| 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 | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width