Remoção pendente no Python 3.15¶
The
PyImport_ImportModuleNoBlock(): usePyImport_ImportModule().PyWeakref_GetObject()ePyWeakref_GET_OBJECT(): UsePyWeakref_GetRef(). O projeto pythoncapi-compat pode ser usado para usarPyWeakref_GetRef()no Python 3.12 e versões anteriores.O tipo
Py_UNICODEe a macroPy_UNICODE_WIDE: usewchar_t.PyUnicode_AsDecodedObject(): usePyCodec_Decode().PyUnicode_AsDecodedUnicode(): UsePyCodec_Decode(); Note que alguns codecs (por exemplo, “base64”) podem retornar um tipo diferente destr, tal comobytes.PyUnicode_AsEncodedObject(): usePyCodec_Encode().PyUnicode_AsEncodedUnicode(): UsePyCodec_Encode(); Note que alguns codecs (por exemplo, “base64”) podem retornar um tipo diferente debytes, tal comstr.Funções de inicialização do Python, descontinuadas no Python 3.9:
Py_GetPath(): UsePyConfig_Get("module_search_paths")(sys.path).Py_GetPrefix(): UsePyConfig_Get("base_prefix")(sys.base_prefix). UsePyConfig_Get("prefix")(sys.prefix) se ambientes virtuais precisam ser tratados.Py_GetExecPrefix(): UsePyConfig_Get("base_exec_prefix")(sys.base_exec_prefix). UsePyConfig_Get("exec_prefix")(sys.exec_prefix) se ambientes virtuais precisam ser tratados.Py_GetProgramFullPath(): UsePyConfig_Get("executable")(sys.executable).Py_GetProgramName(): UsePyConfig_Get("executable")(sys.executable).Py_GetPythonHome(): UsePyConfig_Get("home")ou a variável de ambientePYTHONHOME.
O projeto pythoncapi-compat pode ser usado para obter
PyConfig_Get()no Python 3.13 e versões anteriores.Funções para configurar a inicialização do Python, descontinuadas no Python 3.11:
PySys_SetArgvEx(): definaPyConfig.argv.PySys_SetArgv(): definaPyConfig.argv.Py_SetProgramName(): definaPyConfig.program_name.Py_SetPythonHome(): definaPyConfig.home.PySys_ResetWarnOptions(): apaguesys.warnoptionsewarnings.filters.
Em vez disso, a API
Py_InitializeFromConfig()deve ser usada comPyConfig.Variáveis de configuração globais
Py_DebugFlag: UsePyConfig.parser_debugouPyConfig_Get("parser_debug").Py_VerboseFlag: UsePyConfig.verboseouPyConfig_Get("verbose").Py_InteractiveFlag: UsePyConfig.interactiveouPyConfig_Get("interactive").Py_InspectFlag: UsePyConfig.inspectouPyConfig_Get("inspect").Py_OptimizeFlag: UsePyConfig.optimization_levelouPyConfig_Get("optimization_level").Py_NoSiteFlag: UsePyConfig.site_importouPyConfig_Get("site_import").Py_BytesWarningFlag: UsePyConfig.bytes_warningouPyConfig_Get("bytes_warning").Py_FrozenFlag: UsePyConfig.pathconfig_warningsouPyConfig_Get("pathconfig_warnings").Py_IgnoreEnvironmentFlag: UsePyConfig.use_environmentouPyConfig_Get("use_environment").Py_DontWriteBytecodeFlag: UsePyConfig.write_bytecodeouPyConfig_Get("write_bytecode").Py_NoUserSiteDirectory: UsePyConfig.user_site_directoryouPyConfig_Get("user_site_directory").Py_UnbufferedStdioFlag: UsePyConfig.buffered_stdioouPyConfig_Get("buffered_stdio").Py_HashRandomizationFlag: UsePyConfig.use_hash_seedePyConfig.hash_seedouPyConfig_Get("hash_seed").Py_IsolatedFlag: UsePyConfig.isolatedouPyConfig_Get("isolated").Py_LegacyWindowsFSEncodingFlag: UsePyPreConfig.legacy_windows_fs_encodingouPyConfig_Get("legacy_windows_fs_encoding").Py_LegacyWindowsStdioFlag: UsePyConfig.legacy_windows_stdioouPyConfig_Get("legacy_windows_stdio").Py_FileSystemDefaultEncoding,Py_HasFileSystemDefaultEncoding: UsePyConfig.filesystem_encodingouPyConfig_Get("filesystem_encoding").Py_FileSystemDefaultEncodeErrors: UsePyConfig.filesystem_errorsouPyConfig_Get("filesystem_errors").Py_UTF8Mode: UsePyPreConfig.utf8_modeouPyConfig_Get("utf8_mode"). (vejaPy_PreInitialize())
A API
Py_InitializeFromConfig()deve ser usada comPyConfigpara definir essas opções. OuPyConfig_Get()pode ser usado para obter essas opções em tempo de execução.