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

gh-101865: Deprecateco_lnotab from code objects as per PEP 626#101866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ambv merged 10 commits intopython:mainfromsobolevn:issue-101865
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Deprecateco_lnotab instead of removing it
  • Loading branch information
@sobolevn
sobolevn committedFeb 21, 2023
commit1a6b7bb5f7a22e1cdab3925239b2f662cde7de35
6 changes: 6 additions & 0 deletionsDoc/whatsnew/3.12.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -516,6 +516,12 @@ Pending Removal in Python 3.14
functions that have been deprecated since Python 2 but only gained a
proper :exc:`DeprecationWarning` in 3.12. Remove them in 3.14.

* Accessing ``co_lnotab`` was deprecated in :pep:`626` since 3.10
and was planned to be removed in 3.12
but it only got a proper :exc:`DeprecationWarning` in 3.12.
Remove it in 3.14.
(Contributed by Nikita Sobolev in :gh:`101866`.)

Pending Removal in Future Versions
----------------------------------

Expand Down
7 changes: 7 additions & 0 deletionsLib/test/test_code.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -338,6 +338,13 @@ def func():
new_code = code = func.__code__.replace(co_linetable=b'')
self.assertEqual(list(new_code.co_lines()), [])

def test_co_lnotab_is_deprecated(self): # TODO: remove in 3.14
def func():
pass

with self.assertWarns(DeprecationWarning):
func.__code__.co_lnotab

def test_invalid_bytecode(self):
def foo():
pass
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
Deprecate ``co_lnotab`` in code objects, schedule it for removal in Python
3.14
7 changes: 7 additions & 0 deletionsObjects/codeobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1884,6 +1884,13 @@ static PyMemberDef code_memberlist[] = {
static PyObject *
code_getlnotab(PyCodeObject *code, void *closure)
{
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"co_lnotab is deprecated since Python 3.12 "
"and will be removed in Python 3.14, "
"use co_lines instead.",
1) < 0) {
return NULL;
}
return decode_linetable(code);
}

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp