summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorAlex Waygood <Alex.Waygood@Gmail.com>2023-12-06 20:15:46 (GMT)
committerGitHub <noreply@github.com>2023-12-06 20:15:46 (GMT)
commite9707d3c3deb45a8352e85dbd5cf41afdb4a2a26 (patch)
treeaa298e05382b9f0c64842dd6fd1878bef04afbea /Doc/library
parentb920d6ceaa5532bf2bc8128e006229ec583374d0 (diff)
downloadcpython-e9707d3c3deb45a8352e85dbd5cf41afdb4a2a26.zip
cpython-e9707d3c3deb45a8352e85dbd5cf41afdb4a2a26.tar.gz
cpython-e9707d3c3deb45a8352e85dbd5cf41afdb4a2a26.tar.bz2
gh-101100: Improve documentation of code object attributes (#112781)
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/dis.rst19
-rw-r--r--Doc/library/inspect.rst4
2 files changed, 12 insertions, 11 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index cf238f8..0d93bc9 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -346,8 +346,9 @@ operation is being performed, so the intermediate analysis object isn't useful:
Line numbers can be decreasing. Before, they were always increasing.
.. versionchanged:: 3.10
- The :pep:`626` ``co_lines`` method is used instead of the ``co_firstlineno``
- and ``co_lnotab`` attributes of the code object.
+ The :pep:`626` ``co_lines`` method is used instead of the
+ :attr:`~codeobject.co_firstlineno` and :attr:`~codeobject.co_lnotab`
+ attributes of the code object.
.. versionchanged:: 3.13
Line numbers can be ``None`` for bytecode that does not map to source lines.
@@ -983,13 +984,13 @@ iterations of the loop.
.. opcode:: STORE_NAME (namei)
Implements ``name = STACK.pop()``. *namei* is the index of *name* in the attribute
- :attr:`!co_names` of the :ref:`code object <code-objects>`.
+ :attr:`~codeobject.co_names` of the :ref:`code object <code-objects>`.
The compiler tries to use :opcode:`STORE_FAST` or :opcode:`STORE_GLOBAL` if possible.
.. opcode:: DELETE_NAME (namei)
- Implements ``del name``, where *namei* is the index into :attr:`!co_names`
+ Implements ``del name``, where *namei* is the index into :attr:`~codeobject.co_names`
attribute of the :ref:`code object <code-objects>`.
@@ -1029,7 +1030,7 @@ iterations of the loop.
value = STACK.pop()
obj.name = value
- where *namei* is the index of name in :attr:`!co_names` of the
+ where *namei* is the index of name in :attr:`~codeobject.co_names` of the
:ref:`code object <code-objects>`.
.. opcode:: DELETE_ATTR (namei)
@@ -1039,7 +1040,7 @@ iterations of the loop.
obj = STACK.pop()
del obj.name
- where *namei* is the index of name into :attr:`!co_names` of the
+ where *namei* is the index of name into :attr:`~codeobject.co_names` of the
:ref:`code object <code-objects>`.
@@ -1402,7 +1403,7 @@ iterations of the loop.
Pushes a reference to the object the cell contains on the stack.
.. versionchanged:: 3.11
- ``i`` is no longer offset by the length of ``co_varnames``.
+ ``i`` is no longer offset by the length of :attr:`~codeobject.co_varnames`.
.. opcode:: LOAD_FROM_DICT_OR_DEREF (i)
@@ -1424,7 +1425,7 @@ iterations of the loop.
storage.
.. versionchanged:: 3.11
- ``i`` is no longer offset by the length of ``co_varnames``.
+ ``i`` is no longer offset by the length of :attr:`~codeobject.co_varnames`.
.. opcode:: DELETE_DEREF (i)
@@ -1435,7 +1436,7 @@ iterations of the loop.
.. versionadded:: 3.2
.. versionchanged:: 3.11
- ``i`` is no longer offset by the length of ``co_varnames``.
+ ``i`` is no longer offset by the length of :attr:`~codeobject.co_varnames`.
.. opcode:: COPY_FREE_VARS (n)
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index 08f15ae..0138557 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -1596,8 +1596,8 @@ updated as expected:
Code Objects Bit Flags
----------------------
-Python code objects have a ``co_flags`` attribute, which is a bitmap of
-the following flags:
+Python code objects have a :attr:`~codeobject.co_flags` attribute,
+which is a bitmap of the following flags:
.. data:: CO_OPTIMIZED