-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
inspect.getcallargs() attempts to iterate over None #65015
Comments
Tested in Python 3.3 and Python 3.4.0rc1 5e05d7d3db9c If a function has keyword-only arguments but no keyword-only defaults, then calling inspect.getcallargs with no arguments results in the wrong TypeError being raised. Example:
Result: Expected Result: |
I created a patch to resolve this. If a function has keyword-only arguments, then inspect.getcallargs checks if the argument is in kwonlydefaults. However, kwonlydefaults is None if no defaults were specified. In that situation, 'kwarg in kwonlydefaults' raises the TypeError. The quick fix is simply to test kwonlydefaults before testing if kwarg is in it. The test for this situation is a little verbose because a TypeError is expected and one is raised, just the wrong one, so I parse the error message. |
Apologies, the patch is attached here. |
New changeset 3de2e729d0fb by Yury Selivanov in branch 'default': New changeset 070dfca74610 by Yury Selivanov in branch '3.4': |
Fixed for 3.4.1 and 3.5. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: