summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-08-01 01:07:00 (GMT)
committerGitHub <noreply@github.com>2018-08-01 01:07:00 (GMT)
commit9851227382431a40a138fdff994278d9e7743c74 (patch)
tree01758c7f68b8676d01cffe3ed6601a1d483e6cf8
parenta4d20b2e5ece2120f129cb4dda951a6c2461e92d (diff)
downloadcpython-9851227382431a40a138fdff994278d9e7743c74.zip
cpython-9851227382431a40a138fdff994278d9e7743c74.tar.gz
cpython-9851227382431a40a138fdff994278d9e7743c74.tar.bz2
bpo-34170: Rename _PyCoreConfig.unbuffered_stdip (GH-8594)
* Rename _PyCoreConfig.unbuffered_stdio to buffered_stdio * Rename _PyCoreConfig.debug to parser_debug
-rw-r--r--Include/pystate.h16
-rw-r--r--Lib/test/test_embed.py10
-rw-r--r--Modules/main.c27
-rw-r--r--Programs/_testembed.c8
4 files changed, 33 insertions, 28 deletions
diff --git a/Include/pystate.h b/Include/pystate.h
index bc1e23e..b900843 100644
--- a/Include/pystate.h
+++ b/Include/pystate.h
@@ -148,7 +148,7 @@ typedef struct {
Incremented by the -d command line option. Set by the PYTHONDEBUG
environment variable. If set to -1 (default), inherit Py_DebugFlag
value. */
- int debug;
+ int parser_debug;
/* If equal to 0, Python won't try to write ``.pyc`` files on the
import of source modules.
@@ -185,13 +185,13 @@ typedef struct {
!Py_NoUserSiteDirectory. */
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.
- Set to 1 by the -u option. Set by the PYTHONUNBUFFERED environment
- variable. If set to -1 (default), inherit Py_UnbufferedStdioFlag
- value. */
- int unbuffered_stdio;
+ Set to 0 by the -u option. Set by the PYTHONUNBUFFERED environment
+ variable.
+ If set to -1 (default), it is set to !Py_UnbufferedStdioFlag. */
+ int buffered_stdio;
#ifdef MS_WINDOWS
/* If greater than 1, use the "mbcs" encoding instead of the UTF-8
@@ -268,12 +268,12 @@ typedef struct {
.inspect = -1, \
.interactive = -1, \
.optimization_level = -1, \
- .debug= -1, \
+ .parser_debug= -1, \
.write_bytecode = -1, \
.verbose = -1, \
.quiet = -1, \
.user_site_directory = -1, \
- .unbuffered_stdio = -1, \
+ .buffered_stdio = -1, \
_PyCoreConfig_WINDOWS_INIT \
._install_importlib = 1, \
._frozen = -1}
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index dd7d273..79622f1 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -280,12 +280,12 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'inspect': 0,
'interactive': 0,
'optimization_level': 0,
- 'debug': 0,
+ 'parser_debug': 0,
'write_bytecode': 1,
'verbose': 0,
'quiet': 0,
'user_site_directory': 1,
- 'unbuffered_stdio': 0,
+ 'buffered_stdio': 1,
'_install_importlib': 1,
'_check_hash_pycs_mode': 'default',
@@ -328,7 +328,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'write_bytecode': 0,
'verbose': 1,
'quiet': 1,
- 'unbuffered_stdio': 1,
+ 'buffered_stdio': 0,
'utf8_mode': 1,
'user_site_directory': 0,
'_frozen': 1,
@@ -361,7 +361,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'write_bytecode': 0,
'verbose': 1,
'quiet': 1,
- 'unbuffered_stdio': 1,
+ 'buffered_stdio': 0,
'user_site_directory': 0,
'faulthandler': 1,
@@ -384,7 +384,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'pycache_prefix': 'env_pycache_prefix',
'write_bytecode': 0,
'verbose': 1,
- 'unbuffered_stdio': 1,
+ 'buffered_stdio': 0,
'user_site_directory': 0,
'faulthandler': 1,
'dev_mode': 1,
diff --git a/Modules/main.c b/Modules/main.c
index f0b811b..aef821f 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -565,10 +565,9 @@ _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config)
COPY_FLAG(inspect, Py_InspectFlag);
COPY_FLAG(interactive, Py_InteractiveFlag);
COPY_FLAG(optimization_level, Py_OptimizeFlag);
- COPY_FLAG(debug, Py_DebugFlag);
+ COPY_FLAG(parser_debug, Py_DebugFlag);
COPY_FLAG(verbose, Py_VerboseFlag);
COPY_FLAG(quiet, Py_QuietFlag);
- COPY_FLAG(unbuffered_stdio, Py_UnbufferedStdioFlag);
#ifdef MS_WINDOWS
COPY_FLAG(legacy_windows_fs_encoding, Py_LegacyWindowsFSEncodingFlag);
COPY_FLAG(legacy_windows_stdio, Py_LegacyWindowsStdioFlag);
@@ -576,6 +575,7 @@ _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config)
COPY_FLAG(_frozen, Py_FrozenFlag);
COPY_NOT_FLAG(use_environment, Py_IgnoreEnvironmentFlag);
+ COPY_NOT_FLAG(buffered_stdio, Py_UnbufferedStdioFlag);
COPY_NOT_FLAG(site_import, Py_NoSiteFlag);
COPY_NOT_FLAG(write_bytecode, Py_DontWriteBytecodeFlag);
COPY_NOT_FLAG(user_site_directory, Py_NoUserSiteDirectory);
@@ -608,16 +608,16 @@ _PyCoreConfig_SetGlobalConfig(const _PyCoreConfig *config)
COPY_FLAG(inspect, Py_InspectFlag);
COPY_FLAG(interactive, Py_InteractiveFlag);
COPY_FLAG(optimization_level, Py_OptimizeFlag);
- COPY_FLAG(debug, Py_DebugFlag);
+ COPY_FLAG(parser_debug, Py_DebugFlag);
COPY_FLAG(verbose, Py_VerboseFlag);
COPY_FLAG(quiet, Py_QuietFlag);
- COPY_FLAG(unbuffered_stdio, Py_UnbufferedStdioFlag);
#ifdef MS_WINDOWS
COPY_FLAG(legacy_windows_fs_encoding, Py_LegacyWindowsFSEncodingFlag);
COPY_FLAG(legacy_windows_stdio, Py_LegacyWindowsStdioFlag);
#endif
COPY_NOT_FLAG(use_environment, Py_IgnoreEnvironmentFlag);
+ COPY_NOT_FLAG(buffered_stdio, Py_UnbufferedStdioFlag);
COPY_NOT_FLAG(site_import, Py_NoSiteFlag);
COPY_NOT_FLAG(write_bytecode, Py_DontWriteBytecodeFlag);
COPY_NOT_FLAG(user_site_directory, Py_NoUserSiteDirectory);
@@ -749,12 +749,12 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2)
COPY_ATTR(inspect);
COPY_ATTR(interactive);
COPY_ATTR(optimization_level);
- COPY_ATTR(debug);
+ COPY_ATTR(parser_debug);
COPY_ATTR(write_bytecode);
COPY_ATTR(verbose);
COPY_ATTR(quiet);
COPY_ATTR(user_site_directory);
- COPY_ATTR(unbuffered_stdio);
+ COPY_ATTR(buffered_stdio);
#ifdef MS_WINDOWS
COPY_ATTR(legacy_windows_fs_encoding);
COPY_ATTR(legacy_windows_stdio);
@@ -990,7 +990,7 @@ pymain_parse_cmdline_impl(_PyMain *pymain, _PyCoreConfig *config,
break;
case 'd':
- config->debug++;
+ config->parser_debug++;
break;
case 'i':
@@ -1029,7 +1029,7 @@ pymain_parse_cmdline_impl(_PyMain *pymain, _PyCoreConfig *config,
break;
case 'u':
- config->unbuffered_stdio = 1;
+ config->buffered_stdio = 0;
break;
case 'v':
@@ -1287,7 +1287,7 @@ pymain_init_stdio(_PyMain *pymain, _PyCoreConfig *config)
_setmode(fileno(stderr), O_BINARY);
#endif
- if (config->unbuffered_stdio) {
+ if (!config->buffered_stdio) {
#ifdef HAVE_SETVBUF
setvbuf(stdin, (char *)NULL, _IONBF, BUFSIZ);
setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ);
@@ -1905,7 +1905,7 @@ config_read_env_vars(_PyCoreConfig *config)
assert(config->use_environment > 0);
/* 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->optimization_level, "PYTHONOPTIMIZE");
get_env_flag(config, &config->inspect, "PYTHONINSPECT");
@@ -1922,7 +1922,12 @@ config_read_env_vars(_PyCoreConfig *config)
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
get_env_flag(config, &config->legacy_windows_fs_encoding,
"PYTHONLEGACYWINDOWSFSENCODING");
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index 94db29b..1cdc4c3 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -356,13 +356,13 @@ dump_config(void)
printf("inspect = %i\n", config->inspect);
printf("interactive = %i\n", config->interactive);
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("verbose = %i\n", config->verbose);
ASSERT_EQUAL(config->verbose, Py_VerboseFlag);
printf("quiet = %i\n", config->quiet);
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_stdio */
@@ -509,7 +509,7 @@ static int test_init_from_config(void)
Py_OptimizeFlag = 1;
config.optimization_level = 2;
- /* FIXME: test debug */
+ /* FIXME: test parser_debug */
putenv("PYTHONDONTWRITEBYTECODE=");
Py_DontWriteBytecodeFlag = 0;
@@ -520,7 +520,7 @@ static int test_init_from_config(void)
putenv("PYTHONUNBUFFERED=");
Py_UnbufferedStdioFlag = 0;
- config.unbuffered_stdio = 1;
+ config.buffered_stdio = 0;
putenv("PYTHONNOUSERSITE=");
Py_NoUserSiteDirectory = 0;