From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 61E1C3858C50 for ; Sat, 23 Jul 2022 01:37:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 61E1C3858C50 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-215-RvxZEQPJNhWP1hCYOZBw2Q-1; Fri, 22 Jul 2022 21:37:26 -0400 X-MC-Unique: RvxZEQPJNhWP1hCYOZBw2Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 89F9F2999B26; Sat, 23 Jul 2022 01:37:25 +0000 (UTC) Received: from f35-zws-1 (unknown [10.2.16.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B39D40C1288; Sat, 23 Jul 2022 01:37:24 +0000 (UTC) Date: Fri, 22 Jul 2022 18:37:22 -0700 From: Kevin Buettner To: Eli Zaretskii Cc: gdb-patches@sourceware.org, pedro@palves.net, simark@simark.ca Subject: Re: [PATCH] set/show python dont-write-bytecode fixes Message-ID: <20220722183722.57d34c34@f35-zws-1> In-Reply-To: <83v8rplkfs.fsf@gnu.org> References: <20220720191447.1014407-1-kevinb@redhat.com> <96a7e665-5700-349c-dfc5-50e59ab78fa5@palves.net> <20220721160832.3a1d4b3c@f35-zws-1> <83v8rplkfs.fsf@gnu.org> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jul 2022 01:37:31 -0000 On Fri, 22 Jul 2022 09:40:07 +0300 Eli Zaretskii wrote: > > Date: Thu, 21 Jul 2022 16:08:32 -0700 > > From: Kevin Buettner via Gdb-patches > > Cc: Simon Marchi , 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