Skip to content

gh-125170: Hard deprecate PyEval_GetLocals in 3.14 - #128348

Closed
xuantengh wants to merge 0 commit into
python:mainfrom
xuantengh:deprecate-getlocals
Closed

xuantengh wants to merge 0 commit into
python:mainfrom
xuantengh:deprecate-getlocals

Conversation

@xuantengh

@xuantengh xuantengh commented Dec 30, 2024 •

Copy link
Copy Markdown
Contributor

This PR aims to hard deprecate the PyEval_GetLocals API by emitting a deprecated warning. Meanwhile, this also removes the corresponding tests for the API.

If we consider to deprecate PyFrame_FastToLocals and PyFrame_FastToLocalsWithError as well (mentioned in #125170 (comment)), please let me know. I think they can be done together in this PR.

Comment thread Python/ceval.c Resolved
@ghost

ghost commented Dec 31, 2024 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

@xuantengh
xuantengh force-pushed the deprecate-getlocals branch 2 times, most recently from 04e97fb to 36c1cd0 Compare December 31, 2024 06:05

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. I haven't fully considered the uses of PyEval_GetLocals. It might better to mark it for removal "in the future" so we can adjust it, rather than being constrained to 3.16.

Comment thread Python/ceval.c Outdated
Comment on lines +2602 to +2604
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"PyEval_GetLocals() is deprecated in Python 3.14 "
"and will be removed in 3.16.", 1)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the convention for us:

Suggested change
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"PyEval_GetLocals() is deprecated in Python 3.14 "
"and will be removed in 3.16.", 1)) {
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"PyEval_GetLocals() is deprecated in Python 3.14 "
"and will be removed in 3.16.", 1) < 0) {
@gaogaotiantian

Copy link
Copy Markdown
Member

I don't think we ever reached to a conclusion on whether/how/when we deprecate this API. @ncoghlan @markshannon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants