Pending removal in Python 3.15¶
The
PyImport_ImportModuleNoBlock(): UsePyImport_ImportModule()instead.PyWeakref_GetObject()andPyWeakref_GET_OBJECT(): UsePyWeakref_GetRef()instead. The pythoncapi-compat project can be used to getPyWeakref_GetRef()on Python 3.12 and older.Py_UNICODEtype and thePy_UNICODE_WIDEmacro: Usewchar_tinstead.PyUnicode_AsDecodedObject(): UsePyCodec_Decode()instead.PyUnicode_AsDecodedUnicode(): UsePyCodec_Decode()instead; Note that some codecs (for example, "base64") may return a type other thanstr, such asbytes.PyUnicode_AsEncodedObject(): UsePyCodec_Encode()instead.PyUnicode_AsEncodedUnicode(): UsePyCodec_Encode()instead; Note that some codecs (for example, "base64") may return a type other thanbytes, such asstr.Python initialization functions, deprecated in Python 3.13:
Py_GetPath(): UsePyConfig_Get("module_search_paths")(sys.path) instead.Py_GetPrefix(): UsePyConfig_Get("base_prefix")(sys.base_prefix) instead. UsePyConfig_Get("prefix")(sys.prefix) if virtual environments need to be handled.Py_GetExecPrefix(): UsePyConfig_Get("base_exec_prefix")(sys.base_exec_prefix) instead. UsePyConfig_Get("exec_prefix")(sys.exec_prefix) if virtual environments need to be handled.Py_GetProgramFullPath(): UsePyConfig_Get("executable")(sys.executable) instead.Py_GetProgramName(): UsePyConfig_Get("executable")(sys.executable) instead.Py_GetPythonHome(): UsePyConfig_Get("home")or thePYTHONHOMEenvironment variable instead.
The pythoncapi-compat project can be used to get
PyConfig_Get()on Python 3.13 and older.Functions to configure Python's initialization, deprecated in Python 3.11:
PySys_SetArgvEx(): SetPyConfig.argvinstead.PySys_SetArgv(): SetPyConfig.argvinstead.Py_SetProgramName(): SetPyConfig.program_nameinstead.Py_SetPythonHome(): SetPyConfig.homeinstead.PySys_ResetWarnOptions(): Clearsys.warnoptionsandwarnings.filtersinstead.
The
Py_InitializeFromConfig()API should be used withPyConfiginstead.Global configuration variables:
Py_DebugFlag: UsePyConfig.parser_debugorPyConfig_Get("parser_debug")instead.Py_VerboseFlag: UsePyConfig.verboseorPyConfig_Get("verbose")instead.Py_QuietFlag: UsePyConfig.quietorPyConfig_Get("quiet")instead.Py_InteractiveFlag: UsePyConfig.interactiveorPyConfig_Get("interactive")instead.Py_InspectFlag: UsePyConfig.inspectorPyConfig_Get("inspect")instead.Py_OptimizeFlag: UsePyConfig.optimization_levelorPyConfig_Get("optimization_level")instead.Py_NoSiteFlag: UsePyConfig.site_importorPyConfig_Get("site_import")instead.Py_BytesWarningFlag: UsePyConfig.bytes_warningorPyConfig_Get("bytes_warning")instead.Py_FrozenFlag: UsePyConfig.pathconfig_warningsorPyConfig_Get("pathconfig_warnings")instead.Py_IgnoreEnvironmentFlag: UsePyConfig.use_environmentorPyConfig_Get("use_environment")instead.Py_DontWriteBytecodeFlag: UsePyConfig.write_bytecodeorPyConfig_Get("write_bytecode")instead.Py_NoUserSiteDirectory: UsePyConfig.user_site_directoryorPyConfig_Get("user_site_directory")instead.Py_UnbufferedStdioFlag: UsePyConfig.buffered_stdioorPyConfig_Get("buffered_stdio")instead.Py_HashRandomizationFlag: UsePyConfig.use_hash_seedandPyConfig.hash_seedorPyConfig_Get("hash_seed")instead.Py_IsolatedFlag: UsePyConfig.isolatedorPyConfig_Get("isolated")instead.Py_LegacyWindowsFSEncodingFlag: UsePyPreConfig.legacy_windows_fs_encodingorPyConfig_Get("legacy_windows_fs_encoding")instead.Py_LegacyWindowsStdioFlag: UsePyConfig.legacy_windows_stdioorPyConfig_Get("legacy_windows_stdio")instead.Py_FileSystemDefaultEncoding,Py_HasFileSystemDefaultEncoding: UsePyConfig.filesystem_encodingorPyConfig_Get("filesystem_encoding")instead.Py_FileSystemDefaultEncodeErrors: UsePyConfig.filesystem_errorsorPyConfig_Get("filesystem_errors")instead.Py_UTF8Mode: UsePyPreConfig.utf8_modeorPyConfig_Get("utf8_mode")instead. (seePy_PreInitialize())
The
Py_InitializeFromConfig()API should be used withPyConfigto set these options. OrPyConfig_Get()can be used to get these options at runtime.