| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -312,6 +312,14 @@ typedef struct { | |||
| 312 | 312 | !Py_NoUserSiteDirectory. */ | |
| 313 | 313 | int user_site_directory; | |
| 314 | 314 | ||
| 315 | + /* If non-zero, configure C standard steams (stdio, stdout, | ||
| 316 | + stderr): | ||
| 317 | + | ||
| 318 | + - Set O_BINARY mode on Windows. | ||
| 319 | + - If buffered_stdio is equal to zero, make streams unbuffered. | ||
| 320 | + Otherwise, enable streams buffering if interactive is non-zero. */ | ||
| 321 | + int configure_c_stdio; | ||
| 322 | + | ||
| 315 | 323 | /* If equal to 0, enable unbuffered mode: force the stdout and stderr | |
| 316 | 324 | streams to be unbuffered. | |
| 317 | 325 | ||
@@ -439,6 +447,7 @@ typedef struct { | |||
| 439 | 447 | .verbose = -1, \ | |
| 440 | 448 | .quiet = -1, \ | |
| 441 | 449 | .user_site_directory = -1, \ | |
| 450 | + .configure_c_stdio = 1, \ | ||
| 442 | 451 | .buffered_stdio = -1, \ | |
| 443 | 452 | ._install_importlib = 1, \ | |
| 444 | 453 | .check_hash_pycs_mode = NULL, \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -331,6 +331,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): | |||
| 331 | 331 | 'verbose': 0, | |
| 332 | 332 | 'quiet': 0, | |
| 333 | 333 | 'user_site_directory': 1, | |
| 334 | + 'configure_c_stdio': 1, | ||
| 334 | 335 | 'buffered_stdio': 1, | |
| 335 | 336 | ||
| 336 | 337 | 'stdio_encoding': GET_DEFAULT_CONFIG, | |
@@ -558,6 +559,7 @@ def test_init_global_config(self): | |||
| 558 | 559 | 'filesystem_encoding': 'utf-8', | |
| 559 | 560 | 'filesystem_errors': self.UTF8_MODE_ERRORS, | |
| 560 | 561 | 'user_site_directory': 0, | |
| 562 | + 'pathconfig_warnings': 0, | ||
| 561 | 563 | } | |
| 562 | 564 | self.check_config("init_global_config", config, preconfig) | |
| 563 | 565 | ||
@@ -597,11 +599,13 @@ def test_init_from_config(self): | |||
| 597 | 599 | 'write_bytecode': 0, | |
| 598 | 600 | 'verbose': 1, | |
| 599 | 601 | 'quiet': 1, | |
| 602 | + 'configure_c_stdio': 0, | ||
| 600 | 603 | 'buffered_stdio': 0, | |
| 601 | 604 | 'user_site_directory': 0, | |
| 602 | 605 | 'faulthandler': 1, | |
| 603 | 606 | ||
| 604 | 607 | 'check_hash_pycs_mode': 'always', | |
| 608 | + 'pathconfig_warnings': 0, | ||
| 605 | 609 | } | |
| 606 | 610 | self.check_config("init_from_config", config, preconfig) | |
| 607 | 611 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -360,6 +360,8 @@ static int test_init_global_config(void) | |||
| 360 | 360 | putenv("PYTHONUNBUFFERED="); | |
| 361 | 361 | Py_UnbufferedStdioFlag = 1; | |
| 362 | 362 | ||
| 363 | + Py_FrozenFlag = 1; | ||
| 364 | + | ||
| 363 | 365 | /* FIXME: test Py_LegacyWindowsFSEncodingFlag */ | |
| 364 | 366 | /* FIXME: test Py_LegacyWindowsStdioFlag */ | |
| 365 | 367 | ||
@@ -481,6 +483,8 @@ static int test_init_from_config(void) | |||
| 481 | 483 | Py_QuietFlag = 0; | |
| 482 | 484 | config.quiet = 1; | |
| 483 | 485 | ||
| 486 | + config.configure_c_stdio = 0; | ||
| 487 | + | ||
| 484 | 488 | putenv("PYTHONUNBUFFERED="); | |
| 485 | 489 | Py_UnbufferedStdioFlag = 0; | |
| 486 | 490 | config.buffered_stdio = 0; | |
@@ -501,6 +505,9 @@ static int test_init_from_config(void) | |||
| 501 | 505 | ||
| 502 | 506 | config.check_hash_pycs_mode = L"always"; | |
| 503 | 507 | ||
| 508 | + Py_FrozenFlag = 0; | ||
| 509 | + config.pathconfig_warnings = 0; | ||
| 510 | + | ||
| 504 | 511 | err = _Py_InitializeFromConfig(&config); | |
| 505 | 512 | if (_Py_INIT_FAILED(err)) { | |
| 506 | 513 | _Py_ExitInitError(err); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -654,6 +654,7 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2) | |||
| 654 | 654 | COPY_ATTR(verbose); | |
| 655 | 655 | COPY_ATTR(quiet); | |
| 656 | 656 | COPY_ATTR(user_site_directory); | |
| 657 | + COPY_ATTR(configure_c_stdio); | ||
| 657 | 658 | COPY_ATTR(buffered_stdio); | |
| 658 | 659 | COPY_WSTR_ATTR(filesystem_encoding); | |
| 659 | 660 | COPY_WSTR_ATTR(filesystem_errors); | |
@@ -755,6 +756,7 @@ _PyCoreConfig_AsDict(const _PyCoreConfig *config) | |||
| 755 | 756 | SET_ITEM_INT(verbose); | |
| 756 | 757 | SET_ITEM_INT(quiet); | |
| 757 | 758 | SET_ITEM_INT(user_site_directory); | |
| 759 | + SET_ITEM_INT(configure_c_stdio); | ||
| 758 | 760 | SET_ITEM_INT(buffered_stdio); | |
| 759 | 761 | SET_ITEM_WSTR(stdio_encoding); | |
| 760 | 762 | SET_ITEM_WSTR(stdio_errors); | |
@@ -1582,7 +1584,6 @@ config_read(_PyCoreConfig *config, _PyPreCmdline *cmdline) | |||
| 1582 | 1584 | return _Py_INIT_NO_MEMORY(); | |
| 1583 | 1585 | } | |
| 1584 | 1586 | } | |
| 1585 | - | ||
| 1586 | 1587 | return _Py_INIT_OK(); | |
| 1587 | 1588 | } | |
| 1588 | 1589 | ||
@@ -1632,7 +1633,10 @@ void | |||
| 1632 | 1633 | _PyCoreConfig_Write(const _PyCoreConfig *config, _PyRuntimeState *runtime) | |
| 1633 | 1634 | { | |
| 1634 | 1635 | _PyCoreConfig_SetGlobalConfig(config); | |
| 1635 | - config_init_stdio(config); | ||
| 1636 | + | ||
| 1637 | + if (config->configure_c_stdio) { | ||
| 1638 | + config_init_stdio(config); | ||
| 1639 | + } | ||
| 1636 | 1640 | ||
| 1637 | 1641 | /* Write the new pre-configuration into _PyRuntime */ | |
| 1638 | 1642 | _PyPreConfig *preconfig = &runtime->preconfig; | |
@@ -2067,6 +2071,9 @@ config_read_cmdline(_PyCoreConfig *config, _PyPreCmdline *precmdline) | |||
| 2067 | 2071 | if (config->parse_argv < 0) { | |
| 2068 | 2072 | config->parse_argv = 1; | |
| 2069 | 2073 | } | |
| 2074 | + if (config->configure_c_stdio < 0) { | ||
| 2075 | + config->configure_c_stdio = 1; | ||
| 2076 | + } | ||
| 2070 | 2077 | ||
| 2071 | 2078 | if (config->parse_argv) { | |
| 2072 | 2079 | int opt_index; | |
@@ -2171,7 +2178,9 @@ _PyCoreConfig_SetWideArgv(_PyCoreConfig *config, int argc, wchar_t **argv) | |||
| 2171 | 2178 | ||
| 2172 | 2179 | * Command line arguments | |
| 2173 | 2180 | * Environment variables | |
| 2174 | - * Py_xxx global configuration variables */ | ||
| 2181 | + * Py_xxx global configuration variables | ||
| 2182 | + | ||
| 2183 | + The only side effects are to modify config and to call _Py_SetArgcArgv(). */ | ||
| 2175 | 2184 | _PyInitError | |
| 2176 | 2185 | _PyCoreConfig_Read(_PyCoreConfig *config) | |
| 2177 | 2186 | { | |
@@ -2227,14 +2236,19 @@ _PyCoreConfig_Read(_PyCoreConfig *config) | |||
| 2227 | 2236 | assert(config->quiet >= 0); | |
| 2228 | 2237 | assert(config->user_site_directory >= 0); | |
| 2229 | 2238 | assert(config->parse_argv >= 0); | |
| 2239 | + assert(config->configure_c_stdio >= 0); | ||
| 2230 | 2240 | assert(config->buffered_stdio >= 0); | |
| 2231 | 2241 | assert(config->program_name != NULL); | |
| 2232 | 2242 | assert(config->program != NULL); | |
| 2233 | 2243 | assert(_PyWstrList_CheckConsistency(&config->argv)); | |
| 2244 | + /* sys.argv must be non-empty: empty argv is replaced with [''] */ | ||
| 2245 | + assert(config->argv.length >= 1); | ||
| 2234 | 2246 | assert(_PyWstrList_CheckConsistency(&config->xoptions)); | |
| 2235 | 2247 | assert(_PyWstrList_CheckConsistency(&config->warnoptions)); | |
| 2236 | 2248 | assert(_PyWstrList_CheckConsistency(&config->module_search_paths)); | |
| 2237 | 2249 | if (config->_install_importlib) { | |
| 2250 | + assert(config->use_module_search_paths != 0); | ||
| 2251 | + /* don't check config->module_search_paths */ | ||
| 2238 | 2252 | assert(config->executable != NULL); | |
| 2239 | 2253 | assert(config->prefix != NULL); | |
| 2240 | 2254 | assert(config->base_prefix != NULL); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments