Väntar på borttagning i Python 3.15¶
PyImport_ImportModuleNoBlock()
: AnvändPyImport_ImportModule()
istället.PyWeakref_GetObject()
ochPyWeakref_GET_OBJECT()
: AnvändPyWeakref_GetRef()
istället. Projektet pythoncapi-compat kan användas för att hämtaPyWeakref_GetRef()
på Python 3.12 och äldre.Py_UNICODE
typ ochPy_UNICODE_WIDE
makro: Användwchar_t
istället.PyUnicode_AsDecodedObject()
: AnvändPyCodec_Decode()
istället.PyUnicode_AsDecodedUnicode()
: AnvändPyCodec_Decode()
istället; Observera att vissa codecs (t.ex. ”base64”) kan returnera en annan typ änstr
, t.ex.bytes
.PyUnicode_AsEncodedObject()
: AnvändPyCodec_Encode()
istället.PyUnicode_AsEncodedUnicode()
: AnvändPyCodec_Encode()
istället; Observera att vissa codecs (t.ex. ”base64”) kan returnera en annan typ änbytes
, t.ex.str
.Python-initialiseringsfunktioner, föråldrade i Python 3.13:
Py_GetPath()
: AnvändPyConfig_Get("module_search_paths")
(sys.path
) istället.Py_GetPrefix()
: AnvändPyConfig_Get("base_prefix")
(sys.base_prefix
) istället. AnvändPyConfig_Get("prefix")
(sys.prefix
) om virtuella miljöer behöver hanteras.Py_GetExecPrefix()
: AnvändPyConfig_Get("base_exec_prefix")
(sys.base_exec_prefix
) istället. AnvändPyConfig_Get("exec_prefix")
(sys.exec_prefix
) om virtuella miljöer behöver hanteras.Py_GetProgramFullPath()
: AnvändPyConfig_Get("executable")
(sys.executable
) istället.Py_GetProgramName()
: AnvändPyConfig_Get("executable")
(sys.executable
) istället.Py_GetPythonHome()
: AnvändPyConfig_Get("home")
eller miljövariabelnPYTHONHOME
istället.
Projektet pythoncapi-compat kan användas för att få
PyConfig_Get()
på Python 3.13 och äldre.Funktioner för att konfigurera Pythons initialisering, föråldrad i Python 3.11:
PySys_SetArgvEx()
: Ställ inPyConfig.argv
istället.PySys_SetArgv()
: Ställ inPyConfig.argv
istället.Py_SetProgramName()
: Ställ inPyConfig.program_name
istället.Py_SetPythonHome()
: Ställ inPyConfig.home
istället.PySys_ResetWarnOptions()
: Rensasys.warnoptions
ochwarnings.filters
istället.
API:t
Py_InitializeFromConfig()
bör användas medPyConfig
istället.Variabler för global konfiguration:
Py_DebugFlag
: AnvändPyConfig.parser_debug
ellerPyConfig_Get("parser_debug")
istället.Py_VerboseFlag
: AnvändPyConfig.verbose
ellerPyConfig_Get("verbose")
istället.Py_QuietFlag
: AnvändPyConfig.quiet
ellerPyConfig_Get("quiet")
istället.Py_InteractiveFlag
: AnvändPyConfig.interactive
ellerPyConfig_Get("interactive")
istället.Py_InspectFlag
: AnvändPyConfig.inspect
ellerPyConfig_Get("inspect")
istället.Py_OptimizeFlag
: AnvändPyConfig.optimization_level
ellerPyConfig_Get("optimization_level")
istället.Py_NoSiteFlag
: AnvändPyConfig.site_import
ellerPyConfig_Get("site_import")
istället.Py_BytesWarningFlag
: AnvändPyConfig.bytes_warning
ellerPyConfig_Get("bytes_warning")
istället.Py_FrozenFlag
: AnvändPyConfig.pathconfig_warnings
ellerPyConfig_Get("pathconfig_warnings")
istället.Py_IgnoreEnvironmentFlag
: AnvändPyConfig.use_environment
ellerPyConfig_Get("use_environment")
istället.Py_DontWriteBytecodeFlag
: AnvändPyConfig.write_bytecode
ellerPyConfig_Get("write_bytecode")
istället.Py_NoUserSiteDirectory
: AnvändPyConfig.user_site_directory
ellerPyConfig_Get("user_site_directory")
istället.Py_UnbufferedStdioFlag
: AnvändPyConfig.buffered_stdio
ellerPyConfig_Get("buffered_stdio")
istället.Py_HashRandomizationFlag
: AnvändPyConfig.use_hash_seed
ochPyConfig.hash_seed
ellerPyConfig_Get("hash_seed")
istället.Py_IsolatedFlag
: AnvändPyConfig.isolated
ellerPyConfig_Get("isolated")
istället.Py_LegacyWindowsFSEncodingFlag
: AnvändPyPreConfig.legacy_windows_fs_encoding
ellerPyConfig_Get("legacy_windows_fs_encoding")
istället.Py_LegacyWindowsStdioFlag
: AnvändPyConfig.legacy_windows_stdio
ellerPyConfig_Get("legacy_windows_stdio")
istället.Py_FileSystemDefaultEncoding
,Py_HasFileSystemDefaultEncoding
: AnvändPyConfig.filesystem_encoding
ellerPyConfig_Get("filesystem_encoding")
istället.Py_FileSystemDefaultEncodeErrors
: AnvändPyConfig.filesystem_errors
ellerPyConfig_Get("filesystem_errors")
istället.Py_UTF8Mode
: AnvändPyPreConfig.utf8_mode
ellerPyConfig_Get("utf8_mode")
istället. (sePy_PreInitialize()
)
API:et
Py_InitializeFromConfig()
bör användas medPyConfig
för att ställa in dessa alternativ. Eller så kanPyConfig_Get()
användas för att hämta dessa alternativ vid körning.