mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
bpo-38304: Remove PyConfig.struct_size (GH-16500) (GH-16508)
For now, we'll rely on the fact that the config structures aren't covered by the stable ABI.
We may revisit this in the future if we further explore the idea of offering a stable embedding API.
(cherry picked from commit bdace21b76
)
This commit is contained in:
parent
94e165096f
commit
3c30a76f3d
14 changed files with 39 additions and 273 deletions
|
@ -529,17 +529,6 @@ Py_GetArgcArgv(int *argc, wchar_t ***argv)
|
|||
: _PyStatus_NO_MEMORY())
|
||||
|
||||
|
||||
static PyStatus
|
||||
config_check_struct_size(const PyConfig *config)
|
||||
{
|
||||
if (config->struct_size != sizeof(PyConfig)) {
|
||||
return _PyStatus_ERR("unsupported PyConfig structure size "
|
||||
"(Python version mismatch?)");
|
||||
}
|
||||
return _PyStatus_OK();
|
||||
}
|
||||
|
||||
|
||||
/* Free memory allocated in config, but don't clear all attributes */
|
||||
void
|
||||
PyConfig_Clear(PyConfig *config)
|
||||
|
@ -583,15 +572,7 @@ PyConfig_Clear(PyConfig *config)
|
|||
PyStatus
|
||||
_PyConfig_InitCompatConfig(PyConfig *config)
|
||||
{
|
||||
size_t struct_size = config->struct_size;
|
||||
memset(config, 0, sizeof(*config));
|
||||
config->struct_size = struct_size;
|
||||
|
||||
PyStatus status = config_check_struct_size(config);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
_PyStatus_UPDATE_FUNC(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
config->_config_init = (int)_PyConfig_INIT_COMPAT;
|
||||
config->isolated = -1;
|
||||
|
@ -775,18 +756,6 @@ _PyConfig_Copy(PyConfig *config, const PyConfig *config2)
|
|||
{
|
||||
PyStatus status;
|
||||
|
||||
status = config_check_struct_size(config);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
_PyStatus_UPDATE_FUNC(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = config_check_struct_size(config2);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
_PyStatus_UPDATE_FUNC(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
PyConfig_Clear(config);
|
||||
|
||||
#define COPY_ATTR(ATTR) config->ATTR = config2->ATTR
|
||||
|
@ -2280,7 +2249,6 @@ core_read_precmdline(PyConfig *config, _PyPreCmdline *precmdline)
|
|||
}
|
||||
|
||||
PyPreConfig preconfig;
|
||||
preconfig.struct_size = sizeof(PyPreConfig);
|
||||
|
||||
status = _PyPreConfig_InitFromPreConfig(&preconfig, &_PyRuntime.preconfig);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
|
@ -2475,12 +2443,6 @@ PyConfig_Read(PyConfig *config)
|
|||
PyStatus status;
|
||||
PyWideStringList orig_argv = _PyWideStringList_INIT;
|
||||
|
||||
status = config_check_struct_size(config);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
_PyStatus_UPDATE_FUNC(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = _Py_PreInitializeFromConfig(config, NULL);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue