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_UNICODE
型別與Py_UNICODE_WIDE
巨集:請改用wchar_t
。PyUnicode_AsDecodedObject()
:請改用PyCodec_Decode()
。PyUnicode_AsDecodedUnicode()
:請改用PyCodec_Decode()
;請注意某些編解碼器(例如 "base64")可能會回傳非str
的型別,例如bytes
。PyUnicode_AsEncodedObject()
:請改用PyCodec_Encode()
。PyUnicode_AsEncodedUnicode()
:請改用PyCodec_Encode()
;請注意某些編解碼器(例如 "base64")可能會回傳非bytes
的型別,例如str
。Python 初始化函式,自 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 thePYTHONHOME
environment variable instead.
pythoncapi-compat 專案 可以用來為 Python 3.13 和更早版本取得
PyConfig_Get()
。用於配置 Python 初始化的函式,自 Python 3.11 起已被棄用:
PySys_SetArgvEx()
:請改用PyConfig.argv
。PySys_SetArgv()
:請改用PyConfig.argv
。Py_SetProgramName()
:請改用PyConfig.program_name
。Py_SetPythonHome()
:請改用PyConfig.home
。PySys_ResetWarnOptions()
: Clearsys.warnoptions
andwarnings.filters
instead.
應改用帶有
PyConfig
的Py_InitializeFromConfig()
API。全域配置變數:
Py_DebugFlag
:請改用PyConfig.parser_debug
或PyConfig_Get("parser_debug")
。Py_VerboseFlag
:請改用PyConfig.verbose
或PyConfig_Get("verbose")
。Py_InteractiveFlag
:請改用PyConfig.interactive
或PyConfig_Get("interactive")
。Py_InspectFlag
:請改用PyConfig.inspect
或PyConfig_Get("inspect")
。Py_OptimizeFlag
:請改用PyConfig.optimization_level
或PyConfig_Get("optimization_level")
。Py_NoSiteFlag
:請改用PyConfig.site_import
或PyConfig_Get("site_import")
。Py_BytesWarningFlag
:請改用PyConfig.bytes_warning
或PyConfig_Get("bytes_warning")
。Py_FrozenFlag
:請改用PyConfig.pathconfig_warnings
或PyConfig_Get("pathconfig_warnings")
。Py_IgnoreEnvironmentFlag
:請改用PyConfig.use_environment
或PyConfig_Get("use_environment")
。Py_DontWriteBytecodeFlag
:請改用PyConfig.write_bytecode
或PyConfig_Get("write_bytecode")
。Py_NoUserSiteDirectory
:請改用PyConfig.user_site_directory
或PyConfig_Get("user_site_directory")
。Py_UnbufferedStdioFlag
:請改用PyConfig.buffered_stdio
或PyConfig_Get("buffered_stdio")
。Py_HashRandomizationFlag
:請改用PyConfig.use_hash_seed
和PyConfig.hash_seed
或PyConfig_Get("hash_seed")
。Py_IsolatedFlag
:請改用PyConfig.isolated
或PyConfig_Get("isolated")
。Py_LegacyWindowsFSEncodingFlag
:請改用PyPreConfig.legacy_windows_fs_encoding
或PyConfig_Get("legacy_windows_fs_encoding")
。Py_LegacyWindowsStdioFlag
:請改用PyConfig.legacy_windows_stdio
或PyConfig_Get("legacy_windows_stdio")
。Py_FileSystemDefaultEncoding
、Py_HasFileSystemDefaultEncoding
:請改用PyConfig.filesystem_encoding
或PyConfig_Get("filesystem_encoding")
。Py_FileSystemDefaultEncodeErrors
:請改用PyConfig.filesystem_errors
或PyConfig_Get("filesystem_errors")
。Py_UTF8Mode
:請改用PyPreConfig.utf8_mode
或PyConfig_Get("utf8_mode")
。(請參閱Py_PreInitialize()
)
應改用帶有
PyConfig
的Py_InitializeFromConfig()
API 來設定這些選項。或者也可以使用PyConfig_Get()
在執行時取得這些選項。