gh-105145: Deprecate Py_GetPath() function (#105179)

Deprecate old Python initialization functions:

* PySys_ResetWarnOptions()
* Py_GetExecPrefix()
* Py_GetPath()
* Py_GetPrefix()
* Py_GetProgramFullPath()
* Py_GetProgramName()
* Py_GetPythonHome()

_tkinter.c uses sys.executable instead of Py_GetProgramName()
and uses sys.prefix instead of Py_GetPrefix().
This commit is contained in:
Victor Stinner 2023-06-01 14:06:32 +02:00 committed by GitHub
parent ec0082ca46
commit c67121ac6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 12 deletions

View file

@ -130,11 +130,10 @@ _get_tcl_lib_path(void)
static int already_checked = 0;
if (already_checked == 0) {
PyObject *prefix;
struct stat stat_buf;
int stat_return_value;
prefix = PyUnicode_FromWideChar(Py_GetPrefix(), -1);
PyObject *prefix = PySys_GetObject("prefix"); // borrowed reference
if (prefix == NULL) {
return NULL;
}
@ -3289,8 +3288,8 @@ PyInit__tkinter(void)
/* This helps the dynamic loader; in Unicode aware Tcl versions
it also helps Tcl find its encodings. */
uexe = PyUnicode_FromWideChar(Py_GetProgramName(), -1);
if (uexe) {
uexe = PySys_GetObject("executable"); // borrowed reference
if (uexe && PyUnicode_Check(uexe)) { // sys.executable can be None
cexe = PyUnicode_EncodeFSDefault(uexe);
if (cexe) {
#ifdef MS_WINDOWS
@ -3329,7 +3328,6 @@ PyInit__tkinter(void)
#endif /* MS_WINDOWS */
}
Py_XDECREF(cexe);
Py_DECREF(uexe);
}
if (PyErr_Occurred()) {