Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Include/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
10 changes: 5 additions & 5 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -328,7 +328,7 @@ def test_init_global_config(self):
'write_bytecode': 0,
'verbose': 1,
'quiet': 1,
'unbuffered_stdio': 1,
'buffered_stdio': 0,
'utf8_mode': 1,
'user_site_directory': 0,
'_frozen': 1,
Expand Down Expand Up @@ -361,7 +361,7 @@ def test_init_from_config(self):
'write_bytecode': 0,
'verbose': 1,
'quiet': 1,
'unbuffered_stdio': 1,
'buffered_stdio': 0,
'user_site_directory': 0,
'faulthandler': 1,

Expand All @@ -384,7 +384,7 @@ def test_init_env(self):
'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,
Expand Down
27 changes: 16 additions & 11 deletions Modules/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,17 +565,17 @@ _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);
#endif
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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -990,7 +990,7 @@ pymain_parse_cmdline_impl(_PyMain *pymain, _PyCoreConfig *config,
break;

case 'd':
config->debug++;
config->parser_debug++;
break;

case 'i':
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1902,7 +1902,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");
Expand All @@ -1919,7 +1919,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");
Expand Down
8 changes: 4 additions & 4 deletions Programs/_testembed.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down