bpo-36763: _Py_InitializeFromArgs() argc becomes Py_ssize_t by vstinner · Pull Request #13396 · python/cpython
int void _PyPreConfig_Copy(_PyPreConfig *config, const _PyPreConfig *config2) { #define COPY_ATTR(ATTR) config->ATTR = config2->ATTR #define COPY_STR_ATTR(ATTR) \ do { \ if (config2->ATTR != NULL) { \ config->ATTR = _PyMem_RawStrdup(config2->ATTR); \ if (config->ATTR == NULL) { \ return -1; \ } \ } \ } while (0)
COPY_ATTR(isolated); COPY_ATTR(use_environment); COPY_ATTR(configure_locale); COPY_ATTR(dev_mode); COPY_ATTR(coerce_c_locale); COPY_ATTR(coerce_c_locale_warn); COPY_ATTR(utf8_mode); COPY_ATTR(allocator); #ifdef MS_WINDOWS COPY_ATTR(legacy_windows_fs_encoding); #endif COPY_ATTR(utf8_mode); COPY_ATTR(allocator);
#undef COPY_ATTR #undef COPY_STR_ATTR return 0; }
/* Set LC_CTYPE to the user preferred locale */ if (config->configure_locale) {
/* Write the new pre-configuration into _PyRuntime */ PyMemAllocatorEx old_alloc; _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc); int res = _PyPreConfig_Copy(&_PyRuntime.preconfig, config); PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc); if (res < 0) { return _Py_INIT_NO_MEMORY(); } _PyPreConfig_Copy(&_PyRuntime.preconfig, config);
return _Py_INIT_OK(); }