| 1 |
Pending removal in Python 3.15 |
| 2 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 3 |
|
| 4 |
* The :c:func:`PyImport_ImportModuleNoBlock`: |
| 5 |
Use :c:func:`PyImport_ImportModule` instead. |
| 6 |
* :c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: |
| 7 |
Use :c:func:`PyWeakref_GetRef` instead. The `pythoncapi-compat project |
| 8 |
<https://github.com/python/pythoncapi-compat/>`__ can be used to get |
| 9 |
:c:func:`PyWeakref_GetRef` on Python 3.12 and older. |
| 10 |
* :c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: |
| 11 |
Use :c:type:`wchar_t` instead. |
| 12 |
* :c:func:`!PyUnicode_AsDecodedObject`: |
| 13 |
Use :c:func:`PyCodec_Decode` instead. |
| 14 |
* :c:func:`!PyUnicode_AsDecodedUnicode`: |
| 15 |
Use :c:func:`PyCodec_Decode` instead; Note that some codecs (for example, "base64") |
| 16 |
may return a type other than :class:`str`, such as :class:`bytes`. |
| 17 |
* :c:func:`!PyUnicode_AsEncodedObject`: |
| 18 |
Use :c:func:`PyCodec_Encode` instead. |
| 19 |
* :c:func:`!PyUnicode_AsEncodedUnicode`: |
| 20 |
Use :c:func:`PyCodec_Encode` instead; Note that some codecs (for example, "base64") |
| 21 |
may return a type other than :class:`bytes`, such as :class:`str`. |
| 22 |
* Python initialization functions, deprecated in Python 3.13: |
| 23 |
|
| 24 |
* :c:func:`Py_GetPath`: |
| 25 |
Use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>` |
| 26 |
(:data:`sys.path`) instead. |
| 27 |
* :c:func:`Py_GetPrefix`: |
| 28 |
Use :c:func:`PyConfig_Get("base_prefix") <PyConfig_Get>` |
| 29 |
(:data:`sys.base_prefix`) instead. Use :c:func:`PyConfig_Get("prefix") |
| 30 |
<PyConfig_Get>` (:data:`sys.prefix`) if :ref:`virtual environments |
| 31 |
<venv-def>` need to be handled. |
| 32 |
* :c:func:`Py_GetExecPrefix`: |
| 33 |
Use :c:func:`PyConfig_Get("base_exec_prefix") <PyConfig_Get>` |
| 34 |
(:data:`sys.base_exec_prefix`) instead. Use |
| 35 |
:c:func:`PyConfig_Get("exec_prefix") <PyConfig_Get>` |
| 36 |
(:data:`sys.exec_prefix`) if :ref:`virtual environments <venv-def>` need to |
| 37 |
be handled. |
| 38 |
* :c:func:`Py_GetProgramFullPath`: |
| 39 |
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>` |
| 40 |
(:data:`sys.executable`) instead. |
| 41 |
* :c:func:`Py_GetProgramName`: |
| 42 |
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>` |
| 43 |
(:data:`sys.executable`) instead. |
| 44 |
* :c:func:`Py_GetPythonHome`: |
| 45 |
Use :c:func:`PyConfig_Get("home") <PyConfig_Get>` or the |
| 46 |
:envvar:`PYTHONHOME` environment variable instead. |
| 47 |
|
| 48 |
The `pythoncapi-compat project |
| 49 |
<https://github.com/python/pythoncapi-compat/>`__ can be used to get |
| 50 |
:c:func:`PyConfig_Get` on Python 3.13 and older. |
| 51 |
|
| 52 |
* Functions to configure Python's initialization, deprecated in Python 3.11: |
| 53 |
|
| 54 |
* :c:func:`!PySys_SetArgvEx()`: |
| 55 |
Set :c:member:`PyConfig.argv` instead. |
| 56 |
* :c:func:`!PySys_SetArgv()`: |
| 57 |
Set :c:member:`PyConfig.argv` instead. |
| 58 |
* :c:func:`!Py_SetProgramName()`: |
| 59 |
Set :c:member:`PyConfig.program_name` instead. |
| 60 |
* :c:func:`!Py_SetPythonHome()`: |
| 61 |
Set :c:member:`PyConfig.home` instead. |
| 62 |
* :c:func:`PySys_ResetWarnOptions`: |
| 63 |
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead. |
| 64 |
|
| 65 |
The :c:func:`Py_InitializeFromConfig` API should be used with |
| 66 |
:c:type:`PyConfig` instead. |
| 67 |
|
| 68 |
* Global configuration variables: |
| 69 |
|
| 70 |
* :c:var:`Py_DebugFlag`: |
| 71 |
Use :c:member:`PyConfig.parser_debug` or |
| 72 |
:c:func:`PyConfig_Get("parser_debug") <PyConfig_Get>` instead. |
| 73 |
* :c:var:`Py_VerboseFlag`: |
| 74 |
Use :c:member:`PyConfig.verbose` or |
| 75 |
:c:func:`PyConfig_Get("verbose") <PyConfig_Get>` instead. |
| 76 |
* :c:var:`Py_QuietFlag`: |
| 77 |
Use :c:member:`PyConfig.quiet` or |
| 78 |
:c:func:`PyConfig_Get("quiet") <PyConfig_Get>` instead. |
| 79 |
* :c:var:`Py_InteractiveFlag`: |
| 80 |
Use :c:member:`PyConfig.interactive` or |
| 81 |
:c:func:`PyConfig_Get("interactive") <PyConfig_Get>` instead. |
| 82 |
* :c:var:`Py_InspectFlag`: |
| 83 |
Use :c:member:`PyConfig.inspect` or |
| 84 |
:c:func:`PyConfig_Get("inspect") <PyConfig_Get>` instead. |
| 85 |
* :c:var:`Py_OptimizeFlag`: |
| 86 |
Use :c:member:`PyConfig.optimization_level` or |
| 87 |
:c:func:`PyConfig_Get("optimization_level") <PyConfig_Get>` instead. |
| 88 |
* :c:var:`Py_NoSiteFlag`: |
| 89 |
Use :c:member:`PyConfig.site_import` or |
| 90 |
:c:func:`PyConfig_Get("site_import") <PyConfig_Get>` instead. |
| 91 |
* :c:var:`Py_BytesWarningFlag`: |
| 92 |
Use :c:member:`PyConfig.bytes_warning` or |
| 93 |
:c:func:`PyConfig_Get("bytes_warning") <PyConfig_Get>` instead. |
| 94 |
* :c:var:`Py_FrozenFlag`: |
| 95 |
Use :c:member:`PyConfig.pathconfig_warnings` or |
| 96 |
:c:func:`PyConfig_Get("pathconfig_warnings") <PyConfig_Get>` instead. |
| 97 |
* :c:var:`Py_IgnoreEnvironmentFlag`: |
| 98 |
Use :c:member:`PyConfig.use_environment` or |
| 99 |
:c:func:`PyConfig_Get("use_environment") <PyConfig_Get>` instead. |
| 100 |
* :c:var:`Py_DontWriteBytecodeFlag`: |
| 101 |
Use :c:member:`PyConfig.write_bytecode` or |
| 102 |
:c:func:`PyConfig_Get("write_bytecode") <PyConfig_Get>` instead. |
| 103 |
* :c:var:`Py_NoUserSiteDirectory`: |
| 104 |
Use :c:member:`PyConfig.user_site_directory` or |
| 105 |
:c:func:`PyConfig_Get("user_site_directory") <PyConfig_Get>` instead. |
| 106 |
* :c:var:`Py_UnbufferedStdioFlag`: |
| 107 |
Use :c:member:`PyConfig.buffered_stdio` or |
| 108 |
:c:func:`PyConfig_Get("buffered_stdio") <PyConfig_Get>` instead. |
| 109 |
* :c:var:`Py_HashRandomizationFlag`: |
| 110 |
Use :c:member:`PyConfig.use_hash_seed` |
| 111 |
and :c:member:`PyConfig.hash_seed` or |
| 112 |
:c:func:`PyConfig_Get("hash_seed") <PyConfig_Get>` instead. |
| 113 |
* :c:var:`Py_IsolatedFlag`: |
| 114 |
Use :c:member:`PyConfig.isolated` or |
| 115 |
:c:func:`PyConfig_Get("isolated") <PyConfig_Get>` instead. |
| 116 |
* :c:var:`Py_LegacyWindowsFSEncodingFlag`: |
| 117 |
Use :c:member:`PyPreConfig.legacy_windows_fs_encoding` or |
| 118 |
:c:func:`PyConfig_Get("legacy_windows_fs_encoding") <PyConfig_Get>` instead. |
| 119 |
* :c:var:`Py_LegacyWindowsStdioFlag`: |
| 120 |
Use :c:member:`PyConfig.legacy_windows_stdio` or |
| 121 |
:c:func:`PyConfig_Get("legacy_windows_stdio") <PyConfig_Get>` instead. |
| 122 |
* :c:var:`!Py_FileSystemDefaultEncoding`, :c:var:`!Py_HasFileSystemDefaultEncoding`: |
| 123 |
Use :c:member:`PyConfig.filesystem_encoding` or |
| 124 |
:c:func:`PyConfig_Get("filesystem_encoding") <PyConfig_Get>` instead. |
| 125 |
* :c:var:`!Py_FileSystemDefaultEncodeErrors`: |
| 126 |
Use :c:member:`PyConfig.filesystem_errors` or |
| 127 |
:c:func:`PyConfig_Get("filesystem_errors") <PyConfig_Get>` instead. |
| 128 |
* :c:var:`!Py_UTF8Mode`: |
| 129 |
Use :c:member:`PyPreConfig.utf8_mode` or |
| 130 |
:c:func:`PyConfig_Get("utf8_mode") <PyConfig_Get>` instead. |
| 131 |
(see :c:func:`Py_PreInitialize`) |
| 132 |
|
| 133 |
The :c:func:`Py_InitializeFromConfig` API should be used with |
| 134 |
:c:type:`PyConfig` to set these options. Or :c:func:`PyConfig_Get` can be |
| 135 |
used to get these options at runtime. |