option must be placed into the early initialization file
(@pxref{Initialization Files}) to have the desired effect.
-By default this option is set to @samp{auto}, in this mode Python will
-check the environment variable @env{PYTHONDONTWRITEBYTECODE} to see
+By default this option is set to @samp{auto}. In this mode, provided
+the @code{python ignore-environment} setting is @samp{off}, the
+environment variable @env{PYTHONDONTWRITEBYTECODE} is examined to see
if it should write out byte-code or not.
+@env{PYTHONDONTWRITEBYTECODE} is considered to be off/disabled either
+when set to the empty string or when the environment variable doesn't
+exist. All other settings, including those which don't seem to make
+sense, indicate that it's on/enabled.
This option is equivalent to passing @option{-B} to the real
@command{python} executable.
int wbc = 0;
if (python_dont_write_bytecode == AUTO_BOOLEAN_AUTO)
- wbc = (!python_ignore_environment
- && getenv ("PYTHONDONTWRITEBYTECODE") != nullptr) ? 0 : 1;
+ {
+ if (python_ignore_environment)
+ wbc = 1;
+ else
+ {
+ const char *pdwbc = getenv ("PYTHONDONTWRITEBYTECODE");
+ wbc = (pdwbc == nullptr || pdwbc[0] == '\0') ? 1 : 0;
+ }
+ }
else
wbc = python_dont_write_bytecode == AUTO_BOOLEAN_TRUE ? 0 : 1;
add_setshow_auto_boolean_cmd ("dont-write-bytecode", no_class,
&python_dont_write_bytecode, _("\
-Set whether the Python interpreter should ignore environment variables."), _(" \
-Show whether the Python interpreter showlist ignore environment variables."), _(" \
-When enabled GDB's Python interpreter will ignore any Python related\n \
-flags in the environment. This is equivalent to passing `-E' to a\n \
-python executable."),
+Set whether the Python interpreter should avoid byte-compiling python modules."), _("\
+Show whether the Python interpreter should avoid byte-compiling python modules."), _("\
+When enabled, GDB's embedded Python interpreter won't byte-compile python\n\
+modules. In order to take effect, this setting must be enabled in an early\n\
+initialization file, i.e. those run via the --early-init-eval-command or\n\
+-eix command line options. A 'set python dont-write-bytecode on' command\n\
+can also be issued directly from the GDB command line via the\n\
+--early-init-eval-command or -eiex command line options.\n\
+\n\
+This setting defaults to 'auto'. In this mode, provided the 'python\n\
+ignore-environment' setting is 'off', the environment variable\n\
+PYTHONDONTWRITEBYTECODE is examined to determine whether or not to\n\
+byte-compile python modules. PYTHONDONTWRITEBYTECODE is considered to be\n\
+off/disabled either when set to the empty string or when the\n\
+environment variable doesn't exist. All other settings, including those\n\
+which don't seem to make sense, indicate that it's on/enabled."),
set_python_dont_write_bytecode,
show_python_dont_write_bytecode,
&user_set_python_list,