[issue35265] Internal C API: pass the memory allocator in a context
STINNER Victor
report at bugs.python.org
Fri Nov 16 19:24:03 EST 2018
STINNER Victor <vstinner at redhat.com> added the comment:
Passing the memory allocator is my first goal.
My second goal is to cleanup the code reading the configuration, pymain_read_conf() in Modules/main.c:
int utf8_mode = config->ctx.utf8_mode;
int encoding_changed = 0;
(...)
/* bpo-34207: Py_DecodeLocale() and Py_EncodeLocale() depend
on Py_UTF8Mode and Py_LegacyWindowsFSEncodingFlag. */
Py_UTF8Mode = config->ctx.utf8_mode;
#ifdef MS_WINDOWS
Py_LegacyWindowsFSEncodingFlag = config->legacy_windows_fs_encoding;
#endif
(...)
/* Reset the configuration before reading again the configuration,
just keep UTF-8 Mode value. */
int new_utf8_mode = config->ctx.utf8_mode;
int new_coerce_c_locale = config->coerce_c_locale;
if (_PyCoreConfig_Copy(config, &save_config) < 0) {
pymain->err = _Py_INIT_NO_MEMORY();
goto done;
}
pymain_clear_cmdline(pymain, cmdline);
config->ctx.utf8_mode = new_utf8_mode;
config->coerce_c_locale = new_coerce_c_locale;
/* The encoding changed: read again the configuration
with the new encoding */
My main concern is: "bpo-34207: Py_DecodeLocale() and Py_EncodeLocale() depend on Py_UTF8Mode and Py_LegacyWindowsFSEncodingFlag". Python initialization code should depend on global variables.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35265>
_______________________________________
More information about the Python-bugs-list
mailing list