public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org, pedro@palves.net, simark@simark.ca
Subject: Re: [PATCH] set/show python dont-write-bytecode fixes
Date: Fri, 22 Jul 2022 18:37:22 -0700	[thread overview]
Message-ID: <20220722183722.57d34c34@f35-zws-1> (raw)
In-Reply-To: <83v8rplkfs.fsf@gnu.org>

On Fri, 22 Jul 2022 09:40:07 +0300
Eli Zaretskii <eliz@gnu.org> wrote:

> > Date: Thu, 21 Jul 2022 16:08:32 -0700
> > From: Kevin Buettner via Gdb-patches <gdb-patches@sourceware.org>
> > Cc: Simon Marchi <simark@simark.ca>, gdb-patches@sourceware.org
> > 
> > @@ -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."), _("  
> 
> "Set whether ... won't byte-compile" is a kind-of double negation.
> How about
> 
>  Set whether the Python interpreter should avoid byte-compiling python modules.
> 
> instead (and similar change in the "Show" line)?
> 
> > +When enabled GDB's Python interpreter won't byte-compile python modules.\n\  
>                ^
> Comma missing there.

I've made each of your suggested changes above in my local tree.  I'll
send a v2 patch once we work out the rest (below).

> > +In order to take effect, this setting must be enabled before python\n\
> > +initialization."),  
>
> Will GDB users understand clearly what that means in practical terms?

The GDB manual contains similar (though not identical) wording.  I
referenced the manual while writing the help text.  However, the
manual does contain additional explanation to help the reader
understand how to use the command so that it will actually take
effect.

> Should we say instead "before invoking the Python interpreter for the
> first time"?

We could, but I don't think that your suggested wording is accurate.

My understanding of things is that in order to effectively use 'set
python dont-write-bytecode', it must be placed in an early
initialization file, i.e. those run via the --early-init-eval-command
or -eix options.  If the command were placed in some other
initialization file, it might well be run before the embedded Python
interpreter is run for the first time, yet still not take effect due
to the command being executed after Python initialization.

Another way to make sure that the command takes effect is to
use one of the following options on the GDB command line:

  --early-init-eval-command 'set python dont-write-bytecode on'

or:

  -eiex 'set python dont-write-bytecode on'

> Finally should we mention the PYTHONDONTWRITEBYTECODE environment
> variable?

It is already documented in the GDB manual.  Should it also be
mentioned in the help text?

Another fly in the ointment is that the 'python ignore-environment'
setting also affects how dont-write-bytecode behaves when it's set to
'auto'.  If ignore-environment is 'on', then PYTHONDONTWRITEBYTECODE
is ignored.

This seems like a lot of detail to place in the help text.

IMO, this is an pretty obscure command.  I'm okay with a GDB user
having to ferret out the details from the manual.  However, I am
(also) willing to expand the help text if you think it useful.

I just noticed that, regarding the "auto" setting, the GDB manual says
"... in this mode Python will check the environment variable
PYTHONDONTWRITEBYTECODE to see if it should write out byte-code or
not."  What it doesn't say is what settings the environment variable
must have in order to cause byte-code compilation to be suppressed.
It turns out that any value other than non-existence or the
empty string will enable the supression of byte-code compilation.
I.e. using "PYTHONDONTWRITEBYTECODE=no" might not do what the user
expects.  So, it seems to me that we might update the manual to
make this clear.  (I can include that in the v2 patch if you agree.)

Kevin


  reply	other threads:[~2022-07-23  1:37 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
2022-07-22  6:40     ` Eli Zaretskii
2022-07-23  1:37       ` Kevin Buettner [this message]
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=20220722183722.57d34c34@f35-zws-1 \
    --to=kevinb@redhat.com \
    --cc=eliz@gnu.org \
    --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).