You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
inspect.getargvalues fails if arg name is not bound to a value #61448
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:
assignee=Noneclosed_at=Nonecreated_at=<Date2013-02-19.22:22:36.701>labels= ['easy', 'type-bug', '3.9', '3.10', '3.11', 'library']
title='inspect.getargvalues fails if arg name is not bound to a value'updated_at=<Date2022-03-29.18:46:57.608>user='https://bugs.python.org/AndrewLutomirski'
inspect.formatargvalues assumes (incorrectly) that every argument in args is a key in values. This isn't very hard to break -- see the attachment for a complete example.
Attached a proof-of-concept patch that replaces the missing value with <deleted>. If the approach is ok, the same fix might have to be applied to other functions and/or other types of arguments.
changed the title [-]cgitb fails when frame arguments are deleted (due to inspect bug I think)[/-][+]inspect.getargvalues fails if arg name is not bound to a value[/+]on Jun 18, 2021
In my opinion formatargvalues function is quite useless in current day as ArgInfo provides all the information. I'm however willing to fix this. IMO we should just omit the args/varargs/kwargs that have been deleted, since the values do not exist in the current frame anymore.
I can implement the idea propossed in 2013, but I feel this seems less intuative(?) and might be worse for backwards compatibility (if anyone ever actually expects some values from formatargvalues, but I haven't been able to find an example of that).
Activity
AndrewLutomirski commentedon Feb 19, 2013
inspect.formatargvalues assumes (incorrectly) that every argument in args is a key in values. This isn't very hard to break -- see the attachment for a complete example.
ezio-melotti commentedon Feb 22, 2013
The bug seems to be in inspect indeed:
Attached a proof-of-concept patch that replaces the missing value with <deleted>. If the approach is ok, the same fix might have to be applied to other functions and/or other types of arguments.
iritkatriel commentedon Jun 18, 2021
Still the same in 3.11:
[-]cgitb fails when frame arguments are deleted (due to inspect bug I think)[/-][+]inspect.getargvalues fails if arg name is not bound to a value[/+]macgors commentedon Mar 29, 2022
In my opinion formatargvalues function is quite useless in current day as ArgInfo provides all the information. I'm however willing to fix this. IMO we should just omit the args/varargs/kwargs that have been deleted, since the values do not exist in the current frame anymore.
I can implement the idea propossed in 2013, but I feel this seems less intuative(?) and might be worse for backwards compatibility (if anyone ever actually expects some values from formatargvalues, but I haven't been able to find an example of that).
Thank you in advance for any input.
furkanonder commentedon Mar 7, 2023
The PR is ready for review. @iritkatriel @ezio-melotti
pythongh-61448: Handle all deleted arguments without changing mapping…
gh-61448: Fix inspect.getargvalues fails if arg name is not bound to …