Skip to content

Commit f892097

Browse files
committed
gh-134690: Removed deprecated codetype.co_lnotab
1 parent cf8941c commit f892097

15 files changed

Lines changed: 16 additions & 277 deletions

File tree

Doc/deprecations/pending-removal-in-3.15.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Pending removal in Python 3.15
7070

7171
* :mod:`types`:
7272

73-
* :class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was
73+
* :class:`types.CodeType`: Accessing :attr:`!codeobject.co_lnotab` was
7474
deprecated in :pep:`626`
7575
since 3.10 and was planned to be removed in 3.12,
7676
but it only got a proper :exc:`DeprecationWarning` in 3.12.

Doc/deprecations/pending-removal-in-future.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ although there is currently no date scheduled for their removal.
4949

5050
* :mod:`codecs`: use :func:`open` instead of :func:`codecs.open`. (:gh:`133038`)
5151

52-
* :attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method
52+
* :attr:`!codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method
5353
instead.
5454

5555
* :mod:`datetime`:

Doc/library/dis.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ operation is being performed, so the intermediate analysis object isn't useful:
400400

401401
.. versionchanged:: 3.10
402402
The :pep:`626` :meth:`~codeobject.co_lines` method is used instead of the
403-
:attr:`~codeobject.co_firstlineno` and :attr:`~codeobject.co_lnotab`
403+
:attr:`~codeobject.co_firstlineno` and :attr:`!codeobject.co_lnotab`
404404
attributes of the :ref:`code object <code-objects>`.
405405

406406
.. versionchanged:: 3.13

Doc/library/inspect.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,6 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
198198
| | | read more :ref:`here |
199199
| | | <inspect-module-co-flags>`|
200200
+-----------------+-------------------+---------------------------+
201-
| | co_lnotab | encoded mapping of line |
202-
| | | numbers to bytecode |
203-
| | | indices |
204-
+-----------------+-------------------+---------------------------+
205201
| | co_freevars | tuple of names of free |
206202
| | | variables (referenced via |
207203
| | | a function's closure) |

Doc/reference/datamodel.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,6 @@ indirectly) to mutable objects.
14151415
single: co_filename (code object attribute)
14161416
single: co_firstlineno (code object attribute)
14171417
single: co_flags (code object attribute)
1418-
single: co_lnotab (code object attribute)
14191418
single: co_name (code object attribute)
14201419
single: co_names (code object attribute)
14211420
single: co_nlocals (code object attribute)
@@ -1488,14 +1487,6 @@ Special read-only attributes
14881487
* - .. attribute:: codeobject.co_firstlineno
14891488
- The line number of the first line of the function
14901489

1491-
* - .. attribute:: codeobject.co_lnotab
1492-
- A string encoding the mapping from :term:`bytecode` offsets to line
1493-
numbers. For details, see the source code of the interpreter.
1494-
1495-
.. deprecated:: 3.12
1496-
This attribute of code objects is deprecated, and may be removed in
1497-
Python 3.15.
1498-
14991490
* - .. attribute:: codeobject.co_stacksize
15001491
- The required stack size of the code object
15011492

Doc/whatsnew/3.10.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ Tracing events, with the correct line number, are generated for all lines of cod
402402
The :attr:`~frame.f_lineno` attribute of frame objects will always contain the
403403
expected line number.
404404
405-
The :attr:`~codeobject.co_lnotab` attribute of
405+
The :attr:`!codeobject.co_lnotab` attribute of
406406
:ref:`code objects <code-objects>` is deprecated and
407407
will be removed in 3.12.
408408
Code that needs to convert from offset to line number should use the new

Doc/whatsnew/3.12.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ Deprecated
13331333
``int``, convert to int explicitly: ``~int(x)``. (Contributed by Tim Hoffmann
13341334
in :gh:`103487`.)
13351335

1336-
* Accessing :attr:`~codeobject.co_lnotab` on code objects was deprecated in
1336+
* Accessing :attr:`!codeobject.co_lnotab` on code objects was deprecated in
13371337
Python 3.10 via :pep:`626`,
13381338
but it only got a proper :exc:`DeprecationWarning` in 3.12.
13391339
May be removed in 3.15.

Doc/whatsnew/3.15.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ threading
154154
(Contributed by Bénédikt Tran in :gh:`134087`.)
155155

156156

157+
types
158+
-----
159+
160+
* Removed deprecated in :pep:`626` since Python 3.12
161+
:attr:`!codeobject.co_lnotab` from :class:`types.CodeType`.
162+
(Contributed by Nikita Sobolev in :gh:`134690`.)
163+
164+
157165
typing
158166
------
159167

Doc/whatsnew/3.6.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2173,7 +2173,7 @@ Changes in the Python API
21732173
* :c:func:`PyErr_SetImportError` now sets :exc:`TypeError` when its **msg**
21742174
argument is not set. Previously only ``NULL`` was returned.
21752175

2176-
* The format of the :attr:`~codeobject.co_lnotab` attribute of code objects
2176+
* The format of the :attr:`!codeobject.co_lnotab` attribute of code objects
21772177
changed to support
21782178
a negative line number delta. By default, Python does not emit bytecode with
21792179
a negative line number delta. Functions using :attr:`frame.f_lineno`,

InternalDocs/code_objects.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ The `co_linetable` bytes object of code objects contains a compact
7070
representation of the source code positions of instructions, which are
7171
returned by the `co_positions()` iterator.
7272

73-
> [!NOTE]
74-
> `co_linetable` is not to be confused with `co_lnotab`.
75-
> For backwards compatibility, `co_lnotab` exposes the format
76-
> as it existed in Python 3.10 and lower: this older format
77-
> stores only the start line for each instruction.
78-
> It is lazily created from `co_linetable` when accessed.
79-
> See [`Objects/lnotab_notes.txt`](../Objects/lnotab_notes.txt) for more details.
80-
8173
`co_linetable` consists of a sequence of location entries.
8274
Each entry starts with a byte with the most significant bit set, followed by
8375
zero or more bytes with the most significant bit unset.

0 commit comments

Comments
 (0)