From: Kevin Buettner <kevinb@redhat.com>
To: Pedro Alves <pedro@palves.net>
Cc: gdb-patches@sourceware.org, Simon Marchi <simark@simark.ca>
Subject: Re: [PATCH] set/show python dont-write-bytecode fixes
Date: Thu, 21 Jul 2022 16:08:32 -0700 [thread overview]
Message-ID: <20220721160832.3a1d4b3c@f35-zws-1> (raw)
In-Reply-To: <96a7e665-5700-349c-dfc5-50e59ab78fa5@palves.net>
On Thu, 21 Jul 2022 18:55:35 +0100
Pedro Alves <pedro@palves.net> wrote:
> Hi Kevin,
>
> I just skimmed the patch without paying much attention, but I noticed a typo, below,
> in "intialization".
>
> On 2022-07-20 8:14 p.m., Kevin Buettner via Gdb-patches wrote:
> > +In order to take effect, this setting must be enabled before python\n\
> > +intialization."),
>
Thanks for spotting this!
Fixed - see below:
GDB uses the environment variable PYTHONDONTWRITEBYTECODE to
determine whether or not to write the result of byte-compiling
python modules when the "python dont-write-bytecode" setting
is "auto". Simon noticed that GDB's implementation doesn't
follow the Python documentation.
At present, GDB only checks for the existence of this environment
variable. That is not sufficient though. Regarding
PYTHONDONTWRITEBYTECODE, this document...
https://docs.python.org/3/using/cmdline.html
...says:
If this is set to a non-empty string, Python won't try to write
.pyc files on the import of source modules.
This commit fixes GDB's handling of PYTHONDONTWRITEBYTECODE by adding
an empty string check.
This commit also corrects the set/show command documentation for
"python dont-write-bytecode". The current doc was just a copy
of that for set/show python ignore-environment.
---
gdb/python/python.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/gdb/python/python.c b/gdb/python/python.c
index c7d4157b70c..eef7946f28d 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1866,8 +1866,15 @@ python_write_bytecode ()
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;
@@ -2346,11 +2353,11 @@ python executable."),
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 won't byte-compile python modules."), _("\
+Show whether the Python interpreter won't byte-compile python modules."), _("\
+When enabled GDB's Python interpreter won't byte-compile python modules.\n\
+In order to take effect, this setting must be enabled before python\n\
+initialization."),
set_python_dont_write_bytecode,
show_python_dont_write_bytecode,
&user_set_python_list,
next prev parent reply other threads:[~2022-07-21 23:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-20 19:14 Kevin Buettner
2022-07-21 17:55 ` Pedro Alves
2022-07-21 23:08 ` Kevin Buettner [this message]
2022-07-22 6:40 ` Eli Zaretskii
2022-07-23 1:37 ` Kevin Buettner
2022-07-23 6:54 ` Eli Zaretskii
2022-07-23 21:30 ` Kevin Buettner
2022-07-24 5:41 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220721160832.3a1d4b3c@f35-zws-1 \
--to=kevinb@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@palves.net \
--cc=simark@simark.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).