From da790e969318b69e41b706d046a0bdab7871718e Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 23 Jan 2026 13:07:04 +0100 Subject: [PATCH 1/2] gh-101888: Add function.__builtins__ to ref documentation --- Doc/reference/datamodel.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 1bfe6b7375bcf7..b62fb43c32f3d3 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -556,6 +556,10 @@ Special read-only attributes * - Attribute - Meaning + * - .. attribute:: function.__builtins__ + - A reference to the :class:`dictionary ` that holds the function's + builtins namespace. + * - .. attribute:: function.__globals__ - A reference to the :class:`dictionary ` that holds the function's :ref:`global variables ` -- the global namespace of the module @@ -569,6 +573,10 @@ Special read-only attributes A cell object has the attribute ``cell_contents``. This can be used to get the value of the cell, as well as set the value. +.. versionchanged:: 3.10 + + Add ``__builtins__`` attribute to functions. + Special writable attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 3c211cfef7ee9e9fd0c5be71bc0612be25182abe Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 23 Jan 2026 17:43:47 +0100 Subject: [PATCH 2/2] Address review --- Doc/reference/datamodel.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index b62fb43c32f3d3..f784d963f9d3e1 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -546,6 +546,7 @@ Special read-only attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. index:: + single: __builtins__ (function attribute) single: __closure__ (function attribute) single: __globals__ (function attribute) pair: global; namespace @@ -560,6 +561,8 @@ Special read-only attributes - A reference to the :class:`dictionary ` that holds the function's builtins namespace. + .. versionadded:: 3.10 + * - .. attribute:: function.__globals__ - A reference to the :class:`dictionary ` that holds the function's :ref:`global variables ` -- the global namespace of the module @@ -573,10 +576,6 @@ Special read-only attributes A cell object has the attribute ``cell_contents``. This can be used to get the value of the cell, as well as set the value. -.. versionchanged:: 3.10 - - Add ``__builtins__`` attribute to functions. - Special writable attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~