◐ Shell
clean mode source ↗

gh-108901: Add `inspect.Signature.from_frame` by sobolevn · Pull Request #116537 · python/cpython

I agree, we should drop the defaults part.

>>> import sys, inspect
>>> def f(x=1):
...    print(inspect.getargvalues(sys._getframe()))
...
>>> f()
ArgInfo(args=['x'], varargs=None, keywords=None, locals={'x': 1})

Current API does not show defaults, only locals. But, locals are stored as .f_locals, it is a stable API. Users can use .f_locals to populate defaults, it is quite easy. Later we can add defaults support if users ask for it.

Showing defaults is also not safe in this case by default, for example we can leak things like passwords or secret keys.