Commit 98512273 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-34170: Rename _PyCoreConfig.unbuffered_stdip (GH-8594)

* Rename _PyCoreConfig.unbuffered_stdio to buffered_stdio
* Rename _PyCoreConfig.debug to parser_debug
parent a4d20b2e
...@@ -148,7 +148,7 @@ typedef struct { ...@@ -148,7 +148,7 @@ typedef struct {
Incremented by the -d command line option. Set by the PYTHONDEBUG Incremented by the -d command line option. Set by the PYTHONDEBUG
environment variable. If set to -1 (default), inherit Py_DebugFlag environment variable. If set to -1 (default), inherit Py_DebugFlag
value. */ value. */
int debug; int parser_debug;
/* If equal to 0, Python won't try to write ``.pyc`` files on the /* If equal to 0, Python won't try to write ``.pyc`` files on the
import of source modules. import of source modules.
...@@ -185,13 +185,13 @@ typedef struct { ...@@ -185,13 +185,13 @@ typedef struct {
!Py_NoUserSiteDirectory. */ !Py_NoUserSiteDirectory. */
int user_site_directory; int user_site_directory;
/* If greater than 0, enable unbuffered mode: force the stdout and stderr /* If equal to 0, enable unbuffered mode: force the stdout and stderr
streams to be unbuffered. streams to be unbuffered.
Set to 1 by the -u option. Set by the PYTHONUNBUFFERED environment Set to 0 by the -u option. Set by the PYTHONUNBUFFERED environment
variable. If set to -1 (default), inherit Py_UnbufferedStdioFlag variable.
value. */ If set to -1 (default), it is set to !Py_UnbufferedStdioFlag. */
int unbuffered_stdio; int buffered_stdio;
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
/* If greater than 1, use the "mbcs" encoding instead of the UTF-8 /* If greater than 1, use the "mbcs" encoding instead of the UTF-8
...@@ -268,12 +268,12 @@ typedef struct { ...@@ -268,12 +268,12 @@ typedef struct {
.inspect = -1, \ .inspect = -1, \
.interactive = -1, \ .interactive = -1, \
.optimization_level = -1, \ .optimization_level = -1, \
.debug= -1, \ .parser_debug= -1, \
.write_bytecode = -1, \ .write_bytecode = -1, \
.verbose = -1, \ .verbose = -1, \
.quiet = -1, \ .quiet = -1, \
.user_site_directory = -1, \ .user_site_directory = -1, \
.unbuffered_stdio = -1, \ .buffered_stdio = -1, \
_PyCoreConfig_WINDOWS_INIT \ _PyCoreConfig_WINDOWS_INIT \
._install_importlib = 1, \ ._install_importlib = 1, \
._frozen = -1} ._frozen = -1}
......
...@@ -280,12 +280,12 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): ...@@ -280,12 +280,12 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'inspect': 0, 'inspect': 0,
'interactive': 0, 'interactive': 0,
'optimization_level': 0, 'optimization_level': 0,
'debug': 0, 'parser_debug': 0,
'write_bytecode': 1, 'write_bytecode': 1,
'verbose': 0, 'verbose': 0,
'quiet': 0, 'quiet': 0,
'user_site_directory': 1, 'user_site_directory': 1,
'unbuffered_stdio': 0, 'buffered_stdio': 1,
'_install_importlib': 1, '_install_importlib': 1,
'_check_hash_pycs_mode': 'default', '_check_hash_pycs_mode': 'default',
...@@ -328,7 +328,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): ...@@ -328,7 +328,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'write_bytecode': 0, 'write_bytecode': 0,
'verbose': 1, 'verbose': 1,
'quiet': 1, 'quiet': 1,
'unbuffered_stdio': 1, 'buffered_stdio': 0,
'utf8_mode': 1, 'utf8_mode': 1,
'user_site_directory': 0, 'user_site_directory': 0,
'_frozen': 1, '_frozen': 1,
...@@ -361,7 +361,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): ...@@ -361,7 +361,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'write_bytecode': 0, 'write_bytecode': 0,
'verbose': 1, 'verbose': 1,
'quiet': 1, 'quiet': 1,
'unbuffered_stdio': 1, 'buffered_stdio': 0,
'user_site_directory': 0, 'user_site_directory': 0,
'faulthandler': 1, 'faulthandler': 1,
...@@ -384,7 +384,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): ...@@ -384,7 +384,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'pycache_prefix': 'env_pycache_prefix', 'pycache_prefix': 'env_pycache_prefix',
'write_bytecode': 0, 'write_bytecode': 0,
'verbose': 1, 'verbose': 1,
'unbuffered_stdio': 1, 'buffered_stdio': 0,
'user_site_directory': 0, 'user_site_directory': 0,
'faulthandler': 1, 'faulthandler': 1,
'dev_mode': 1, 'dev_mode': 1,
......
...@@ -565,10 +565,9 @@ _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config) ...@@ -565,10 +565,9 @@ _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config)
COPY_FLAG(inspect, Py_InspectFlag); COPY_FLAG(inspect, Py_InspectFlag);
COPY_FLAG(interactive, Py_InteractiveFlag); COPY_FLAG(interactive, Py_InteractiveFlag);
COPY_FLAG(optimization_level, Py_OptimizeFlag); COPY_FLAG(optimization_level, Py_OptimizeFlag);
COPY_FLAG(debug, Py_DebugFlag); COPY_FLAG(parser_debug, Py_DebugFlag);
COPY_FLAG(verbose, Py_VerboseFlag); COPY_FLAG(verbose, Py_VerboseFlag);
COPY_FLAG(quiet, Py_QuietFlag); COPY_FLAG(quiet, Py_QuietFlag);
COPY_FLAG(unbuffered_stdio, Py_UnbufferedStdioFlag);
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
COPY_FLAG(legacy_windows_fs_encoding, Py_LegacyWindowsFSEncodingFlag); COPY_FLAG(legacy_windows_fs_encoding, Py_LegacyWindowsFSEncodingFlag);
COPY_FLAG(legacy_windows_stdio, Py_LegacyWindowsStdioFlag); COPY_FLAG(legacy_windows_stdio, Py_LegacyWindowsStdioFlag);
...@@ -576,6 +575,7 @@ _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config) ...@@ -576,6 +575,7 @@ _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config)
COPY_FLAG(_frozen, Py_FrozenFlag); COPY_FLAG(_frozen, Py_FrozenFlag);
COPY_NOT_FLAG(use_environment, Py_IgnoreEnvironmentFlag); COPY_NOT_FLAG(use_environment, Py_IgnoreEnvironmentFlag);
COPY_NOT_FLAG(buffered_stdio, Py_UnbufferedStdioFlag);
COPY_NOT_FLAG(site_import, Py_NoSiteFlag); COPY_NOT_FLAG(site_import, Py_NoSiteFlag);
COPY_NOT_FLAG(write_bytecode, Py_DontWriteBytecodeFlag); COPY_NOT_FLAG(write_bytecode, Py_DontWriteBytecodeFlag);
COPY_NOT_FLAG(user_site_directory, Py_NoUserSiteDirectory); COPY_NOT_FLAG(user_site_directory, Py_NoUserSiteDirectory);
...@@ -608,16 +608,16 @@ _PyCoreConfig_SetGlobalConfig(const _PyCoreConfig *config) ...@@ -608,16 +608,16 @@ _PyCoreConfig_SetGlobalConfig(const _PyCoreConfig *config)
COPY_FLAG(inspect, Py_InspectFlag); COPY_FLAG(inspect, Py_InspectFlag);
COPY_FLAG(interactive, Py_InteractiveFlag); COPY_FLAG(interactive, Py_InteractiveFlag);
COPY_FLAG(optimization_level, Py_OptimizeFlag); COPY_FLAG(optimization_level, Py_OptimizeFlag);
COPY_FLAG(debug, Py_DebugFlag); COPY_FLAG(parser_debug, Py_DebugFlag);
COPY_FLAG(verbose, Py_VerboseFlag); COPY_FLAG(verbose, Py_VerboseFlag);
COPY_FLAG(quiet, Py_QuietFlag); COPY_FLAG(quiet, Py_QuietFlag);
COPY_FLAG(unbuffered_stdio, Py_UnbufferedStdioFlag);
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
COPY_FLAG(legacy_windows_fs_encoding, Py_LegacyWindowsFSEncodingFlag); COPY_FLAG(legacy_windows_fs_encoding, Py_LegacyWindowsFSEncodingFlag);
COPY_FLAG(legacy_windows_stdio, Py_LegacyWindowsStdioFlag); COPY_FLAG(legacy_windows_stdio, Py_LegacyWindowsStdioFlag);
#endif #endif
COPY_NOT_FLAG(use_environment, Py_IgnoreEnvironmentFlag); COPY_NOT_FLAG(use_environment, Py_IgnoreEnvironmentFlag);
COPY_NOT_FLAG(buffered_stdio, Py_UnbufferedStdioFlag);
COPY_NOT_FLAG(site_import, Py_NoSiteFlag); COPY_NOT_FLAG(site_import, Py_NoSiteFlag);
COPY_NOT_FLAG(write_bytecode, Py_DontWriteBytecodeFlag); COPY_NOT_FLAG(write_bytecode, Py_DontWriteBytecodeFlag);
COPY_NOT_FLAG(user_site_directory, Py_NoUserSiteDirectory); COPY_NOT_FLAG(user_site_directory, Py_NoUserSiteDirectory);
...@@ -749,12 +749,12 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2) ...@@ -749,12 +749,12 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2)
COPY_ATTR(inspect); COPY_ATTR(inspect);
COPY_ATTR(interactive); COPY_ATTR(interactive);
COPY_ATTR(optimization_level); COPY_ATTR(optimization_level);
COPY_ATTR(debug); COPY_ATTR(parser_debug);
COPY_ATTR(write_bytecode); COPY_ATTR(write_bytecode);
COPY_ATTR(verbose); COPY_ATTR(verbose);
COPY_ATTR(quiet); COPY_ATTR(quiet);
COPY_ATTR(user_site_directory); COPY_ATTR(user_site_directory);
COPY_ATTR(unbuffered_stdio); COPY_ATTR(buffered_stdio);
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
COPY_ATTR(legacy_windows_fs_encoding); COPY_ATTR(legacy_windows_fs_encoding);
COPY_ATTR(legacy_windows_stdio); COPY_ATTR(legacy_windows_stdio);
...@@ -990,7 +990,7 @@ pymain_parse_cmdline_impl(_PyMain *pymain, _PyCoreConfig *config, ...@@ -990,7 +990,7 @@ pymain_parse_cmdline_impl(_PyMain *pymain, _PyCoreConfig *config,
break; break;
case 'd': case 'd':
config->debug++; config->parser_debug++;
break; break;
case 'i': case 'i':
...@@ -1029,7 +1029,7 @@ pymain_parse_cmdline_impl(_PyMain *pymain, _PyCoreConfig *config, ...@@ -1029,7 +1029,7 @@ pymain_parse_cmdline_impl(_PyMain *pymain, _PyCoreConfig *config,
break; break;
case 'u': case 'u':
config->unbuffered_stdio = 1; config->buffered_stdio = 0;
break; break;
case 'v': case 'v':
...@@ -1287,7 +1287,7 @@ pymain_init_stdio(_PyMain *pymain, _PyCoreConfig *config) ...@@ -1287,7 +1287,7 @@ pymain_init_stdio(_PyMain *pymain, _PyCoreConfig *config)
_setmode(fileno(stderr), O_BINARY); _setmode(fileno(stderr), O_BINARY);
#endif #endif
if (config->unbuffered_stdio) { if (!config->buffered_stdio) {
#ifdef HAVE_SETVBUF #ifdef HAVE_SETVBUF
setvbuf(stdin, (char *)NULL, _IONBF, BUFSIZ); setvbuf(stdin, (char *)NULL, _IONBF, BUFSIZ);
setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ); setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ);
...@@ -1905,7 +1905,7 @@ config_read_env_vars(_PyCoreConfig *config) ...@@ -1905,7 +1905,7 @@ config_read_env_vars(_PyCoreConfig *config)
assert(config->use_environment > 0); assert(config->use_environment > 0);
/* Get environment variables */ /* Get environment variables */
get_env_flag(config, &config->debug, "PYTHONDEBUG"); get_env_flag(config, &config->parser_debug, "PYTHONDEBUG");
get_env_flag(config, &config->verbose, "PYTHONVERBOSE"); get_env_flag(config, &config->verbose, "PYTHONVERBOSE");
get_env_flag(config, &config->optimization_level, "PYTHONOPTIMIZE"); get_env_flag(config, &config->optimization_level, "PYTHONOPTIMIZE");
get_env_flag(config, &config->inspect, "PYTHONINSPECT"); get_env_flag(config, &config->inspect, "PYTHONINSPECT");
...@@ -1922,7 +1922,12 @@ config_read_env_vars(_PyCoreConfig *config) ...@@ -1922,7 +1922,12 @@ config_read_env_vars(_PyCoreConfig *config)
config->user_site_directory = 0; config->user_site_directory = 0;
} }
get_env_flag(config, &config->unbuffered_stdio, "PYTHONUNBUFFERED"); int unbuffered_stdio = 0;
get_env_flag(config, &unbuffered_stdio, "PYTHONUNBUFFERED");
if (unbuffered_stdio) {
config->buffered_stdio = 0;
}
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
get_env_flag(config, &config->legacy_windows_fs_encoding, get_env_flag(config, &config->legacy_windows_fs_encoding,
"PYTHONLEGACYWINDOWSFSENCODING"); "PYTHONLEGACYWINDOWSFSENCODING");
......
...@@ -356,13 +356,13 @@ dump_config(void) ...@@ -356,13 +356,13 @@ dump_config(void)
printf("inspect = %i\n", config->inspect); printf("inspect = %i\n", config->inspect);
printf("interactive = %i\n", config->interactive); printf("interactive = %i\n", config->interactive);
printf("optimization_level = %i\n", config->optimization_level); printf("optimization_level = %i\n", config->optimization_level);
printf("debug = %i\n", config->debug); printf("parser_debug = %i\n", config->parser_debug);
printf("write_bytecode = %i\n", config->write_bytecode); printf("write_bytecode = %i\n", config->write_bytecode);
printf("verbose = %i\n", config->verbose); printf("verbose = %i\n", config->verbose);
ASSERT_EQUAL(config->verbose, Py_VerboseFlag); ASSERT_EQUAL(config->verbose, Py_VerboseFlag);
printf("quiet = %i\n", config->quiet); printf("quiet = %i\n", config->quiet);
printf("user_site_directory = %i\n", config->user_site_directory); printf("user_site_directory = %i\n", config->user_site_directory);
printf("unbuffered_stdio = %i\n", config->unbuffered_stdio); printf("buffered_stdio = %i\n", config->buffered_stdio);
/* FIXME: test legacy_windows_fs_encoding */ /* FIXME: test legacy_windows_fs_encoding */
/* FIXME: test legacy_windows_stdio */ /* FIXME: test legacy_windows_stdio */
...@@ -509,7 +509,7 @@ static int test_init_from_config(void) ...@@ -509,7 +509,7 @@ static int test_init_from_config(void)
Py_OptimizeFlag = 1; Py_OptimizeFlag = 1;
config.optimization_level = 2; config.optimization_level = 2;
/* FIXME: test debug */ /* FIXME: test parser_debug */
putenv("PYTHONDONTWRITEBYTECODE="); putenv("PYTHONDONTWRITEBYTECODE=");
Py_DontWriteBytecodeFlag = 0; Py_DontWriteBytecodeFlag = 0;
...@@ -520,7 +520,7 @@ static int test_init_from_config(void) ...@@ -520,7 +520,7 @@ static int test_init_from_config(void)
putenv("PYTHONUNBUFFERED="); putenv("PYTHONUNBUFFERED=");
Py_UnbufferedStdioFlag = 0; Py_UnbufferedStdioFlag = 0;
config.unbuffered_stdio = 1; config.buffered_stdio = 0;
putenv("PYTHONNOUSERSITE="); putenv("PYTHONNOUSERSITE=");
Py_NoUserSiteDirectory = 0; Py_NoUserSiteDirectory = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment