Skip to content

Commit 85d3bcd

Browse files
authored
pythongh-134690: Removed deprecated codetype.co_lnotab (python#134691)
1 parent 6d7bbee commit 85d3bcd

15 files changed

Lines changed: 16 additions & 348 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
@@ -60,7 +60,7 @@ Pending removal in Python 3.15
6060

6161
* :mod:`types`:
6262

63-
* :class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was
63+
* :class:`types.CodeType`: Accessing :attr:`!codeobject.co_lnotab` was
6464
deprecated in :pep:`626`
6565
since 3.10 and was planned to be removed in 3.12,
6666
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
@@ -47,7 +47,7 @@ although there is currently no date scheduled for their removal.
4747

4848
* :mod:`codecs`: use :func:`open` instead of :func:`codecs.open`. (:gh:`133038`)
4949

50-
* :attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method
50+
* :attr:`!codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method
5151
instead.
5252

5353
* :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
@@ -195,10 +195,6 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
195195
| | | read more :ref:`here |
196196
| | | <inspect-module-co-flags>`|
197197
+-----------------+-------------------+---------------------------+
198-
| | co_lnotab | encoded mapping of line |
199-
| | | numbers to bytecode |
200-
| | | indices |
201-
+-----------------+-------------------+---------------------------+
202198
| | co_freevars | tuple of names of free |
203199
| | | variables (referenced via |
204200
| | | a function's closure) |

Doc/reference/datamodel.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,6 @@ indirectly) to mutable objects.
14761476
single: co_filename (code object attribute)
14771477
single: co_firstlineno (code object attribute)
14781478
single: co_flags (code object attribute)
1479-
single: co_lnotab (code object attribute)
14801479
single: co_name (code object attribute)
14811480
single: co_names (code object attribute)
14821481
single: co_nlocals (code object attribute)
@@ -1549,14 +1548,6 @@ Special read-only attributes
15491548
* - .. attribute:: codeobject.co_firstlineno
15501549
- The line number of the first line of the function
15511550

1552-
* - .. attribute:: codeobject.co_lnotab
1553-
- A string encoding the mapping from :term:`bytecode` offsets to line
1554-
numbers. For details, see the source code of the interpreter.
1555-
1556-
.. deprecated:: 3.12
1557-
This attribute of code objects is deprecated, and may be removed in
1558-
Python 3.15.
1559-
15601551
* - .. attribute:: codeobject.co_stacksize
15611552
- The required stack size of the code object
15621553

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
@@ -1347,7 +1347,7 @@ Deprecated
13471347
``int``, convert to int explicitly: ``~int(x)``. (Contributed by Tim Hoffmann
13481348
in :gh:`103487`.)
13491349

1350-
* Accessing :attr:`~codeobject.co_lnotab` on code objects was deprecated in
1350+
* Accessing :attr:`!codeobject.co_lnotab` on code objects was deprecated in
13511351
Python 3.10 via :pep:`626`,
13521352
but it only got a proper :exc:`DeprecationWarning` in 3.12.
13531353
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
@@ -1658,6 +1658,14 @@ threading
16581658
(Contributed by Bénédikt Tran in :gh:`134087`.)
16591659

16601660

1661+
types
1662+
-----
1663+
1664+
* Removed deprecated in :pep:`626` since Python 3.12
1665+
:attr:`!codeobject.co_lnotab` from :class:`types.CodeType`.
1666+
(Contributed by Nikita Sobolev in :gh:`134690`.)
1667+
1668+
16611669
typing
16621670
------
16631671

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)