[PATCH 7/7] gdb: startup commands to control Python extension language
Andrew Burgess
andrew.burgess@embecosm.com
Thu Apr 29 09:46:42 GMT 2021
* Tom de Vries <tdevries@suse.de> [2021-04-29 10:32:05 +0200]:
> I ran into https://sourceware.org/bugzilla/show_bug.cgi?id=27788 due to
> having PYTHONDONTWRITEBYTECODE set in my environment. My guess at this
> point is that this is a test-case issue.
>
> I played around a bit with the options and did:
> ...
> $ echo $PYTHONDONTWRITEBYTECODE
> 1
>
> $ gdb -q -batch \
> -iex "set python ignore-environment on" \
> -iex "show python dont-write-bytecode"
> Python's dont-write-bytecode setting is auto (currently off).
>
> $ gdb -q -batch \
> -iex "set python ignore-environment off" \
> -iex "show python dont-write-bytecode"
> Python's dont-write-bytecode setting is auto (currently on).
> ...
> which shows that there is an interaction between the two commands.
> AFAICT, this is not evident from either the NEWS item, or the docs, and
> I just wonder whether it's a good idea to make this explicit.
Hi Tom,
Thanks for looking at this feature.
The docs for dont-write-bytecode say:
<snip>
By default this option is set to @samp{auto}, in this mode Python will
check the environment variable @env{PYTHONDONTWRITEBYTECODE} to see
if it should write out byte-code or not.
<snip>
I guess you saw this, but it still didn't seem clear enough?
What if this was extended to something like:
By default this option is set to @samp{auto}, in this mode Python will
check the environment variable @env{PYTHONDONTWRITEBYTECODE} to see
if it should write out byte-code or not. When @command{set python
ignore-environment on} has been used then Python will ignore
the environment variable and write out the byte-code files.
I've included the patch below that would make this change.
Thanks,
Andrew
---
commit 1557998d9d8e9b0587500980bd8731bb55a1c299
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date: Thu Apr 29 10:45:17 2021 +0100
gdb/doc: improve description of set python dont-write-bytecode
Extend the description of 'set python dont-write-bytecode' to make the
interaction with 'set python ignore-environment' clearer.
gdb/doc/ChangeLog:
* python.texinfo (Python Commands): Extend description of 'set
python dont-write-bytecode'.
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 20d65742964..26e1446f005 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -136,8 +136,10 @@
(@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
-if it should write out byte-code or not.
+check the environment variable @env{PYTHONDONTWRITEBYTECODE} to see if
+it should write out byte-code or not. When @command{set python
+ignore-environment on} has been used then Python will ignore the
+environment variable and write out the byte-code files.
This option is equivalent to passing @option{-B} to the real
@command{python} executable.
More information about the Gdb-patches
mailing list