Author vstinner
Recipients eric.snow, ncoghlan, vstinner
Date 2018-11-17.00:24:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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;
        Py_LegacyWindowsFSEncodingFlag = config->legacy_windows_fs_encoding;


        /* 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.
Date User Action Args
2018-11-17 00:24:03vstinnersetrecipients: + vstinner, ncoghlan, eric.snow
2018-11-17 00:24:03vstinnersetmessageid: <>
2018-11-17 00:24:03vstinnerlinkissue35265 messages
2018-11-17 00:24:03vstinnercreate