In solving issue 42990 the func_builtins field of PyFunctionObject, added in 3.9, was exposed to python as func.__builtins__ and this was documented in the release notes for 3.10:
Functions have a new __builtins__ attribute which is used to look for builtin symbols when a function is executed, instead of looking into __globals__['__builtins__']. The attribute is initialized from __globals__["__builtins__"] if it exists, else from the current builtins. (Contributed by Mark Shannon in bpo-42990.), the actual PR is #24559 by @vstinner.
The added attribute is not documented in the "User-defined functions" table of attributes in the data model (that page could use some internal structure so I could link to an anchor). I think it should be if it is part of the language model, or is this a CPython implementation detail? From the discussion in the issue, it seems the former is true: it is part of the language model.
Documentation
In solving issue 42990 the
func_builtins
field ofPyFunctionObject
, added in 3.9, was exposed to python asfunc.__builtins__
and this was documented in the release notes for 3.10:The added attribute is not documented in the "User-defined functions" table of attributes in the data model (that page could use some internal structure so I could link to an anchor). I think it should be if it is part of the language model, or is this a CPython implementation detail? From the discussion in the issue, it seems the former is true: it is part of the language model.