[issue44113] [C API] Deprecate legacy API for configure Python initialization
New submission from STINNER Victor <vstinner@python.org>: The https://docs.python.org/dev/c-api/init.html documentation lists many functions which is the legacy way to configure the Python initialization. These functions are kept for backward compatibility but have flaws and are less reliable than the new PyConfig API (PEP 587) documented at https://docs.python.org/dev/c-api/init_config.html I propose to deprecate the legacy functions to configure the Python initialization. Examples: * Py_SetPath() * Py_SetProgramName() * Py_SetPythonHome() * Py_SetStandardStreamEncoding() * PySys_AddWarnOption() * PySys_AddWarnOptionUnicode() * PySys_AddXOption() I don't propose to schedule the removal of these functions, only mark them as deprecated in the *documentation*. Related issue: bpo-43956 "C-API: Incorrect default value for Py_SetProgramName" and PR 24876. ---------- assignee: docs@python components: C API, Documentation messages: 393499 nosy: docs@python, vstinner priority: normal severity: normal status: open title: [C API] Deprecate legacy API for configure Python initialization versions: Python 3.11 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
Change by STINNER Victor <vstinner@python.org>: ---------- keywords: +patch pull_requests: +24700 stage: -> patch review pull_request: https://github.com/python/cpython/pull/26060 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
Change by Jouke Witteveen <j.witteveen@gmail.com>: ---------- nosy: +joukewitteveen nosy_count: 2.0 -> 3.0 pull_requests: +24701 pull_request: https://github.com/python/cpython/pull/24876 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
Change by Dong-hee Na <donghee.na@python.org>: ---------- nosy: +corona10 nosy_count: 3.0 -> 4.0 pull_requests: +24722 pull_request: https://github.com/python/cpython/pull/26083 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
STINNER Victor <vstinner@python.org> added the comment: PyConfig API was added to Python 3.8, so it's now widely available. Python 3.8 always switched to security fixes only phase. So IMO it's ok to deprecate the old API now. ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
Change by STINNER Victor <vstinner@python.org>: ---------- pull_requests: +24723 pull_request: https://github.com/python/cpython/pull/26084 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
STINNER Victor <vstinner@python.org> added the comment: """ Check warning on line 82 in Python/frozenmain.c GitHub Actions / Ubuntu ‘Py_SetProgramName’ is deprecated [-Wdeprecated-declarations] """ Well, Py_FrozenMain() should be rewritten with PyConfig, I want to do that for a long time, but I don't know how to test it. It would be nice to have a very basic test for Py_FrozenMain(). See also: https://mail.python.org/archives/list/capi-sig@python.org/thread/5QLI3NUP3OS... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
Change by Dong-hee Na <donghee.na@python.org>: ---------- pull_requests: +24724 pull_request: https://github.com/python/cpython/pull/26085 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
STINNER Victor <vstinner@python.org> added the comment: commit 6cd0446ef72c6676b292d7f54b1ddb8ae5e1fb8d Author: Victor Stinner <vstinner@python.org> Date: Wed May 12 23:59:25 2021 +0200 bpo-44113: Deprecate old functions to config Python init (GH-26060) Deprecate the following functions to configure the Python initialization: * PySys_AddWarnOption() * PySys_AddWarnOptionUnicode() * PySys_AddXOption() * PySys_HasWarnOptions() * Py_SetPath() * Py_SetProgramName() * Py_SetPythonHome() * Py_SetStandardStreamEncoding() * _Py_SetProgramFullPath() Use the new PyConfig API of the Python Initialization Configuration instead (PEP 587). commit a0ccc404ca649c2a1635511a09df2454e47b4d66 Author: Dong-hee Na <donghee.na@python.org> Date: Thu May 13 08:22:18 2021 +0900 bpo-44113: Update __xxtestfuzz not to use Py_SetProgramName (GH-26083) commit ec7c09b9bc9a8f333a0295b41ea88986c320448c Author: Victor Stinner <vstinner@python.org> Date: Thu May 13 02:27:56 2021 +0200 bpo-44113: Fix compiler warning in PySys_AddWarnOption() (GH-26084) Ignore Py_DEPRECATED() warning on purpose. ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
STINNER Victor <vstinner@python.org> added the comment: commit 7565586724692e2ad164d770af9675f7a261fe3a Author: Dong-hee Na <donghee.na@python.org> Date: Thu May 13 10:19:46 2021 +0900 bpo-44113: Update fromzenmain not to use Py_SetProgramName (GH-26085) ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
STINNER Victor <vstinner@python.org> added the comment:
Well, Py_FrozenMain() should be rewritten with PyConfig, I want to do that for a long time, but I don't know how to test it. It would be nice to have a very basic test for Py_FrozenMain().
I created bpo-44131: [C API] Add tests on Py_FrozenMain(). ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
STINNER Victor <vstinner@python.org> added the comment: Thanks for the help Dong-hee ;-) I close the issue, functions are now deprecated. ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
Change by STINNER Victor <vstinner@python.org>: ---------- pull_requests: +27262 pull_request: https://github.com/python/cpython/pull/28974 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
STINNER Victor <vstinner@python.org> added the comment: New changeset a7f8dfd25a167ccfde9996c499fa38a2aba60022 by Victor Stinner in branch 'main': bpo-44113: Move the What's New entry to Deprecate section (GH-28974) https://github.com/python/cpython/commit/a7f8dfd25a167ccfde9996c499fa38a2aba... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue44113> _______________________________________
participants (3)
-
Dong-hee Na
-
Jouke Witteveen
-
STINNER Victor