This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: inspect.getcallargs() raises the wrong error if 3+ arguments are missing
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3, Python 3.4
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: yselivanov Nosy List: jlowin, larry, ncoghlan, python-dev, yselivanov
Priority: normal Keywords: patch

Created on 2014-03-01 16:35 by jlowin, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
issue20817.patch jlowin, 2014-03-01 16:38 review
Messages (4)
msg212514 - (view) Author: Jeremiah Lowin (jlowin) * Date: 2014-03-01 16:35
If inspect.getcallargs() is called on a function and three or more arguments are missing, an IndexError is raised instead of the expected TypeError.

This bug is present in Python 3.3 and 3.4.0 rc1 (5e05d7d3db9c). However, it worked as expected in Python 2.7.6.


>>> import inspect
>>> def fn(a, b, c):
>>>     pass
>>> inspect.getcallargs(fn)

    IndexError: tuple index out of range
    TypeError: fn() missing 3 required positional arguments: 'a', 'b' and 'c'
msg212515 - (view) Author: Jeremiah Lowin (jlowin) * Date: 2014-03-01 16:38
The bug is caused by a list of names not getting properly expanded when generating the error message. This patch fixes it (simply by adding a * in the appropriate place) and tests that a TypeError, not an IndexError, is raised.
msg214988 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-03-27 22:45
New changeset 35302cc4fc93 by Yury Selivanov in branch 'default':
inspect: Fix getcallargs() to fail correctly if more than 3 args are missing.

New changeset 9f06cbb7962b by Yury Selivanov in branch '3.4':
inspect: Fix getcallargs() to fail correctly if more than 3 args are missing.
msg214989 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2014-03-27 22:46
Fixed for 3.4.1 and 3.5.
Thanks for the contribution!
Date User Action Args
2022-04-11 14:57:59adminsetgithub: 65016
2014-03-27 22:46:06yselivanovsetmessages: + msg214989
2014-03-27 22:45:42python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg214988

resolution: fixed
stage: resolved
2014-03-01 18:39:44yselivanovsetassignee: yselivanov

nosy: + larry, yselivanov, ncoghlan
2014-03-01 16:38:40jlowinsetfiles: + issue20817.patch
keywords: + patch
messages: + msg212515
2014-03-01 16:35:04jlowincreate