.. versionchanged:: 3.10
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
+ .. deprecated-removed:: 3.13 3.15
+ Get :data:`sys.executable` instead.
+
.. c:function:: wchar_t* Py_GetPrefix()
.. versionchanged:: 3.10
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
+ .. deprecated-removed:: 3.13 3.15
+ Get :data:`sys.prefix` instead.
+
.. c:function:: wchar_t* Py_GetExecPrefix()
.. versionchanged:: 3.10
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
+ .. deprecated-removed:: 3.13 3.15
+ Get :data:`sys.exec_prefix` instead.
+
.. c:function:: wchar_t* Py_GetProgramFullPath()
.. versionchanged:: 3.10
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
+ .. deprecated-removed:: 3.13 3.15
+ Get :data:`sys.executable` instead.
+
.. c:function:: wchar_t* Py_GetPath()
.. versionchanged:: 3.10
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
+ .. deprecated-removed:: 3.13 3.15
+ Get :data:`sys.path` instead.
+
.. c:function:: const char* Py_GetVersion()
.. versionchanged:: 3.10
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
+ .. deprecated-removed:: 3.13 3.15
+ Get :c:member:`PyConfig.home` or :envvar:`PYTHONHOME` environment
+ variable instead.
+
.. _threads:
Reset :data:`sys.warnoptions` to an empty list. This function may be
called prior to :c:func:`Py_Initialize`.
+ .. deprecated-removed:: 3.13 3.15
+ Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
+
.. c:function:: void PySys_WriteStdout(const char *format, ...)
Write the output string described by *format* to :data:`sys.stdout`. No
``PY_UNICODE_TYPE`` are just aliases to ``wchar_t``.
(Contributed by Victor Stinner in :gh:`105156`.)
+* Deprecate old Python initialization functions:
+
+ * :c:func:`PySys_ResetWarnOptions`:
+ clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
+ * :c:func:`Py_GetExecPrefix`: get :data:`sys.exec_prefix` instead.
+ * :c:func:`Py_GetPath`: get :data:`sys.path` instead.
+ * :c:func:`Py_GetPrefix`: get :data:`sys.prefix` instead.
+ * :c:func:`Py_GetProgramFullPath`: get :data:`sys.executable` instead.
+ * :c:func:`Py_GetProgramName`: get :data:`sys.executable` instead.
+ * :c:func:`Py_GetPythonHome`: get :c:member:`PyConfig.home` or
+ :envvar:`PYTHONHOME` environment variable instead.
+
+ (Contributed by Victor Stinner in :gh:`105145`.)
+
Removed
-------
PyAPI_FUNC(int) Py_BytesMain(int argc, char **argv);
/* In pathconfig.c */
-PyAPI_FUNC(wchar_t *) Py_GetProgramName(void);
-PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void);
-PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void);
-PyAPI_FUNC(wchar_t *) Py_GetPrefix(void);
-PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void);
-PyAPI_FUNC(wchar_t *) Py_GetPath(void);
+Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetProgramName(void);
+Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void);
+Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void);
+Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetPrefix(void);
+Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void);
+Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetPath(void);
#ifdef MS_WINDOWS
int _Py_CheckPython3(void);
#endif
PyAPI_FUNC(void) PySys_FormatStdout(const char *format, ...);
PyAPI_FUNC(void) PySys_FormatStderr(const char *format, ...);
-PyAPI_FUNC(void) PySys_ResetWarnOptions(void);
+Py_DEPRECATED(3.13) PyAPI_FUNC(void) PySys_ResetWarnOptions(void);
PyAPI_FUNC(PyObject *) PySys_GetXOptions(void);
--- /dev/null
+Deprecate old Python initialization functions:
+
+* :c:func:`PySys_ResetWarnOptions`
+* :c:func:`Py_GetExecPrefix`
+* :c:func:`Py_GetPath`
+* :c:func:`Py_GetPrefix`
+* :c:func:`Py_GetProgramFullPath`
+* :c:func:`Py_GetProgramName`
+* :c:func:`Py_GetPythonHome`
+
+Patch by Victor Stinner.
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;
}
/* 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
#endif /* MS_WINDOWS */
}
Py_XDECREF(cexe);
- Py_DECREF(uexe);
}
if (PyErr_Occurred()) {