-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-129342: Explain how to replace Py_GetProgramName() in C #129361
base: main
Are you sure you want to change the base?
Conversation
Doc/c-api/init.rst
Outdated
@@ -622,7 +622,8 @@ Process-wide parameters | |||
It now returns ``NULL`` if called before :c:func:`Py_Initialize`. | |||
|
|||
.. deprecated-removed:: 3.13 3.15 | |||
Get :data:`sys.executable` instead. | |||
Use ``PySys_GetObject("executable")`` (:data:`sys.executable`) or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that PyConfig_Get("executable")
is more preferable in a new code, isn't it?
PySys_GetObject()
will be deprecated in future (it returns a borrowed reference and silences errors).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PySys_GetObject() works on all Python versions, whereas PyConfig_Get() is new in Python 3.14. The note can be updated once PySys_GetObject() will be deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should suggest first what will work in future versions. We do not want users to rewrite the same code twice (and curse us twice).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PySys_GetObject() works on all Python versions, whereas PyConfig_Get() is new in Python 3.14.
I don't understand; this PR is for the 3.14 docs, so it should be ok to mention new-in-3.14 APIs here, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, I would prefer to provide a replacement working on old Python versions as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the PR to use only PyConfig_Get()
.
@@ -622,7 +622,8 @@ Process-wide parameters | |||
It now returns ``NULL`` if called before :c:func:`Py_Initialize`. | |||
|
|||
.. deprecated-removed:: 3.13 3.15 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should postpone hard deprecation until there is a non-deprecated replacement that works in all maintained Python versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PySys_GetObject() works on all Python versions, it's not deprecated: https://docs.python.org/dev/c-api/sys.html#c.PySys_GetObject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use pythoncapi-compat to get PyConfig_Get() on Python 3.13 and older.
@serhiy-storchaka: I think that we already had this discusssion about |
Much better than status quo, but in my opinion not sufficient to resolve #129342. Imagine the worst-case scenario, which is exactly what happened to me: Somebody has to maintain a huge amount of C code, with lots of dependencies, and without being an expert for each library dependency. Such a user, after hitting a deprecation warning, needs complete, self-contained instructions how to replace the deprecated code. The current MR won't do, because the functions proposed for replacement return a different data type than the deprecated functions. Therefore, in addition to the changes proposed here, we need a link to a separate page that explains how to replace a function that returned a |
If you have a Python |
Excellent. Just two sentences to be added to each deprecation note. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good to me.
📚 Documentation preview 📚: https://cpython-previews--129361.org.readthedocs.build/