From 0a8c95b12c0d13be5cd6889d3bf266bab62b0a78 Mon Sep 17 00:00:00 2001 From: harjoth Date: Fri, 12 Jun 2026 18:12:29 -0700 Subject: [PATCH] gh-137528: Document the co_linetable code object attribute Document the public ``codeobject.co_linetable`` attribute in the data model reference. It holds encoded source location information in an opaque, version-specific format and is exposed to support the creation of new code objects; readers are pointed to ``co_lines()`` and ``co_positions()`` for supported access. --- Doc/reference/datamodel.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 2a961a062780f4..0880d2b54901ad 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1489,6 +1489,7 @@ indirectly) to mutable objects. single: co_consts (code object attribute) single: co_filename (code object attribute) single: co_firstlineno (code object attribute) + single: co_linetable (code object attribute) single: co_flags (code object attribute) single: co_name (code object attribute) single: co_names (code object attribute) @@ -1562,6 +1563,16 @@ Special read-only attributes * - .. attribute:: codeobject.co_firstlineno - The line number of the first line of the function + * - .. attribute:: codeobject.co_linetable + - A :class:`bytes` object containing encoded source location information. + The exact format is an implementation detail and may change between + Python versions. It is made available to support the creation of new + code objects; use :meth:`~codeobject.co_lines` and + :meth:`~codeobject.co_positions` for supported access to line and + position information. + + .. versionadded:: 3.10 + * - .. attribute:: codeobject.co_stacksize - The required stack size of the code object