Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a6b7bb

Browse files
committed
Deprecateco_lnotab instead of removing it
1 parentdd65849 commit1a6b7bb

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

‎Doc/whatsnew/3.12.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,12 @@ Pending Removal in Python 3.14
516516
functions that have been deprecated since Python 2 but only gained a
517517
proper:exc:`DeprecationWarning` in 3.12. Remove them in 3.14.
518518

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+
519525
Pending Removal in Future Versions
520526
----------------------------------
521527

‎Lib/test/test_code.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,13 @@ def func():
338338
new_code=code=func.__code__.replace(co_linetable=b'')
339339
self.assertEqual(list(new_code.co_lines()), [])
340340

341+
deftest_co_lnotab_is_deprecated(self):# TODO: remove in 3.14
342+
deffunc():
343+
pass
344+
345+
withself.assertWarns(DeprecationWarning):
346+
func.__code__.co_lnotab
347+
341348
deftest_invalid_bytecode(self):
342349
deffoo():
343350
pass
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Deprecate ``co_lnotab`` in code objects, schedule it for removal in Python
2+
3.14

‎Objects/codeobject.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,13 @@ static PyMemberDef code_memberlist[] = {
18841884
staticPyObject*
18851885
code_getlnotab(PyCodeObject*code,void*closure)
18861886
{
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+
returnNULL;
1893+
}
18871894
returndecode_linetable(code);
18881895
}
18891896

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp