File tree 4 files changed +22
-0
lines changed
Misc/NEWS.d/next/Core and Builtins
4 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -516,6 +516,12 @@ Pending Removal in Python 3.14
516
516
functions that have been deprecated since Python 2 but only gained a
517
517
proper :exc: `DeprecationWarning ` in 3.12. Remove them in 3.14.
518
518
519
+ * Accessing ``co_lnotab `` was deprecated in :pep: `626 ` since 3.10
520
+ and was planned to be removed in 3.12
521
+ but it only got a proper :exc: `DeprecationWarning ` in 3.12.
522
+ Remove it in 3.14.
523
+ (Contributed by Nikita Sobolev in :gh: `101866 `.)
524
+
519
525
Pending Removal in Future Versions
520
526
----------------------------------
521
527
Original file line number Diff line number Diff line change @@ -338,6 +338,13 @@ def func():
338
338
new_code = code = func .__code__ .replace (co_linetable = b'' )
339
339
self .assertEqual (list (new_code .co_lines ()), [])
340
340
341
+ def test_co_lnotab_is_deprecated (self ): # TODO: remove in 3.14
342
+ def func ():
343
+ pass
344
+
345
+ with self .assertWarns (DeprecationWarning ):
346
+ func .__code__ .co_lnotab
347
+
341
348
def test_invalid_bytecode (self ):
342
349
def foo ():
343
350
pass
Original file line number Diff line number Diff line change
1
+ Deprecate ``co_lnotab `` in code objects, schedule it for removal in Python
2
+ 3.14
Original file line number Diff line number Diff line change @@ -1884,6 +1884,13 @@ static PyMemberDef code_memberlist[] = {
1884
1884
static PyObject *
1885
1885
code_getlnotab (PyCodeObject * code , void * closure )
1886
1886
{
1887
+ if (PyErr_WarnEx (PyExc_DeprecationWarning ,
1888
+ "co_lnotab is deprecated since Python 3.12 "
1889
+ "and will be removed in Python 3.14, "
1890
+ "use co_lines instead." ,
1891
+ 1 ) < 0 ) {
1892
+ return NULL ;
1893
+ }
1887
1894
return decode_linetable (code );
1888
1895
}
1889
1896
You can’t perform that action at this time.
0 commit comments