bpo-36142: Add _PyPreConfig.utf8_mode (GH-12174) · python/cpython@5a02e0d

@@ -60,12 +60,42 @@ typedef struct {

6060

Set to 0 by -E command line option. If set to -1 (default), it is

6161

set to !Py_IgnoreEnvironmentFlag. */

6262

int use_environment;

63+64+

int coerce_c_locale; /* PYTHONCOERCECLOCALE, -1 means unknown */

65+

int coerce_c_locale_warn; /* PYTHONCOERCECLOCALE=warn */

66+67+

#ifdef MS_WINDOWS

68+

/* If greater than 1, use the "mbcs" encoding instead of the UTF-8

69+

encoding for the filesystem encoding.

70+71+

Set to 1 if the PYTHONLEGACYWINDOWSFSENCODING environment variable is

72+

set to a non-empty string. If set to -1 (default), inherit

73+

Py_LegacyWindowsFSEncodingFlag value.

74+75+

See PEP 529 for more details. */

76+

int legacy_windows_fs_encoding;

77+

#endif

78+79+

/* Enable UTF-8 mode?

80+

Set by -X utf8 command line option and PYTHONUTF8 environment variable.

81+

If set to -1 (default), inherit Py_UTF8Mode value. */

82+

int utf8_mode;

6383

} _PyPreConfig;

648485+

#ifdef MS_WINDOWS

86+

# define _PyPreConfig_WINDOWS_INIT \

87+

.legacy_windows_fs_encoding = -1,

88+

#else

89+

# define _PyPreConfig_WINDOWS_INIT

90+

#endif

91+6592

#define _PyPreConfig_INIT \

6693

(_PyPreConfig){ \

94+

_PyPreConfig_WINDOWS_INIT \

6795

.isolated = -1, \

68-

.use_environment = -1}

96+

.use_environment = -1, \

97+

.coerce_c_locale = -1, \

98+

.utf8_mode = -1}

69997010071101

/* --- _PyCoreConfig ---------------------------------------------- */

@@ -95,8 +125,6 @@ typedef struct {

95125

int show_alloc_count; /* -X showalloccount */

96126

int dump_refs; /* PYTHONDUMPREFS */

97127

int malloc_stats; /* PYTHONMALLOCSTATS */

98-

int coerce_c_locale; /* PYTHONCOERCECLOCALE, -1 means unknown */

99-

int coerce_c_locale_warn; /* PYTHONCOERCECLOCALE=warn */

100128101129

/* Python filesystem encoding and error handler:

102130

sys.getfilesystemencoding() and sys.getfilesystemencodeerrors().

@@ -134,11 +162,6 @@ typedef struct {

134162

char *filesystem_encoding;

135163

char *filesystem_errors;

136164137-

/* Enable UTF-8 mode?

138-

Set by -X utf8 command line option and PYTHONUTF8 environment variable.

139-

If set to -1 (default), inherit Py_UTF8Mode value. */

140-

int utf8_mode;

141-142165

wchar_t *pycache_prefix; /* PYTHONPYCACHEPREFIX, -X pycache_prefix=PATH */

143166144167

wchar_t *program_name; /* Program name, see also Py_GetProgramName() */

@@ -277,16 +300,6 @@ typedef struct {

277300

char *stdio_errors;

278301279302

#ifdef MS_WINDOWS

280-

/* If greater than 1, use the "mbcs" encoding instead of the UTF-8

281-

encoding for the filesystem encoding.

282-283-

Set to 1 if the PYTHONLEGACYWINDOWSFSENCODING environment variable is

284-

set to a non-empty string. If set to -1 (default), inherit

285-

Py_LegacyWindowsFSEncodingFlag value.

286-287-

See PEP 529 for more details. */

288-

int legacy_windows_fs_encoding;

289-290303

/* If greater than zero, use io.FileIO instead of WindowsConsoleIO for sys

291304

standard streams.

292305

@@ -340,21 +353,19 @@ typedef struct {

340353341354

#ifdef MS_WINDOWS

342355

# define _PyCoreConfig_WINDOWS_INIT \

343-

.legacy_windows_fs_encoding = -1, \

344356

.legacy_windows_stdio = -1,

345357

#else

346358

# define _PyCoreConfig_WINDOWS_INIT

347359

#endif

348360349361

#define _PyCoreConfig_INIT \

350362

(_PyCoreConfig){ \

363+

_PyCoreConfig_WINDOWS_INIT \

351364

.preconfig = _PyPreConfig_INIT, \

352365

.install_signal_handlers = 1, \

353366

.use_hash_seed = -1, \

354367

.faulthandler = -1, \

355368

.tracemalloc = -1, \

356-

.coerce_c_locale = -1, \

357-

.utf8_mode = -1, \

358369

.argc = -1, \

359370

.nmodule_search_path = -1, \

360371

.site_import = -1, \

@@ -368,7 +379,6 @@ typedef struct {

368379

.quiet = -1, \

369380

.user_site_directory = -1, \

370381

.buffered_stdio = -1, \

371-

_PyCoreConfig_WINDOWS_INIT \

372382

._install_importlib = 1, \

373383

._check_hash_pycs_mode = "default", \

374384

._frozen = -1}