public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/32388] New: [gdb/python] Warn on setting python dont-write-bytecode/ignore-environment after python initialization
@ 2024-11-25 8:12 vries at gcc dot gnu.org
2024-11-27 14:17 ` [Bug python/32388] " vries at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2024-11-25 8:12 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=32388
Bug ID: 32388
Summary: [gdb/python] Warn on setting python
dont-write-bytecode/ignore-environment after python
initialization
Product: gdb
Version: HEAD
Status: NEW
Severity: enhancement
Priority: P2
Component: python
Assignee: unassigned at sourceware dot org
Reporter: vries at gcc dot gnu.org
Target Milestone: ---
Python configuration flags "dont-write-bytecode" and "ignore-environment" are
meant to have effect only before python initialization.
When setting these after python initialization, they are silently ignored
(though that is not evident from the gdb code either).
Instead, a warning should be emitted.
Likewise, there could be some mention of this here:
...
(gdb) show python
python dont-write-bytecode: Python's dont-write-bytecode setting is auto
(currently on).
python ignore-environment: Python's ignore-environment setting is off.
...
This gives the impression of something that is still settable and has effect,
even though python initialization has already happened.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug python/32388] [gdb/python] Warn on setting python dont-write-bytecode/ignore-environment after python initialization
2024-11-25 8:12 [Bug python/32388] New: [gdb/python] Warn on setting python dont-write-bytecode/ignore-environment after python initialization vries at gcc dot gnu.org
@ 2024-11-27 14:17 ` vries at gcc dot gnu.org
2024-12-03 21:48 ` cvs-commit at gcc dot gnu.org
2024-12-03 21:49 ` vries at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2024-11-27 14:17 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=32388
--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/pipermail/gdb-patches/2024-November/213636.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug python/32388] [gdb/python] Warn on setting python dont-write-bytecode/ignore-environment after python initialization
2024-11-25 8:12 [Bug python/32388] New: [gdb/python] Warn on setting python dont-write-bytecode/ignore-environment after python initialization vries at gcc dot gnu.org
2024-11-27 14:17 ` [Bug python/32388] " vries at gcc dot gnu.org
@ 2024-12-03 21:48 ` cvs-commit at gcc dot gnu.org
2024-12-03 21:49 ` vries at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-12-03 21:48 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=32388
--- Comment #2 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=348290c7ef4b731f3ff851d7922d038e671fea4a
commit 348290c7ef4b731f3ff851d7922d038e671fea4a
Author: Tom de Vries <tdevries@suse.de>
Date: Tue Dec 3 22:49:40 2024 +0100
[gdb/python] Warn and ignore ineffective python settings
Configuration flags "python dont-write-bytecode" and
"python ignore-environment" have effect only at Python initialization.
For instance, setting "python dont-write-bytecode" here has no effect:
...
$ gdb -q
(gdb) show python dont-write-bytecode
Python's dont-write-bytecode setting is auto (currently off).
(gdb) python import sys
(gdb) python print (sys.dont_write_bytecode)
False
(gdb) set python dont-write-bytecode on
(gdb) python print (sys.dont_write_bytecode)
False
...
This is not clear in the code: we set Py_DontWriteBytecodeFlag and
Py_IgnoreEnvironmentFlag in set_python_ignore_environment and
set_python_dont_write_bytecode. Fix this by moving the setting of those
variables to py_initialization.
Furthermore, this is not clear to the user: after Python initialization,
the
user can still modify the configuration flags, and observe the changed
setting:
...
$ gdb -q
(gdb) show python ignore-environment
Python's ignore-environment setting is off.
(gdb) set python ignore-environment on
(gdb) show python ignore-environment
Python's ignore-environment setting is on.
(gdb)
...
Fix this by emitting a warning when trying to set these configuration flags
after Python initialization:
...
$ gdb -q
(gdb) set python ignore-environment on
warning: Setting python ignore-environment after Python initialization has
\
no effect, try setting this during early initialization
(gdb) set python dont-write-bytecode on
warning: Setting python dont-write-bytecode after Python initialization has
\
no effect, try setting this during early initialization, or try setting \
sys.dont_write_bytecode
...
and by keeping the values constant after Python initialization.
Since the auto setting for python dont-write-bytecode depends on the
current
value of environment variable PYTHONDONTWRITEBYTECODE, we simply avoid it
after Python initialization:
...
$ gdb -q -batch \
-eiex "show python dont-write-bytecode" \
-iex "show python dont-write-bytecode"
Python's dont-write-bytecode setting is auto (currently off).
Python's dont-write-bytecode setting is off.
...
Tested on aarch64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
PR python/32388
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32388
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug python/32388] [gdb/python] Warn on setting python dont-write-bytecode/ignore-environment after python initialization
2024-11-25 8:12 [Bug python/32388] New: [gdb/python] Warn on setting python dont-write-bytecode/ignore-environment after python initialization vries at gcc dot gnu.org
2024-11-27 14:17 ` [Bug python/32388] " vries at gcc dot gnu.org
2024-12-03 21:48 ` cvs-commit at gcc dot gnu.org
@ 2024-12-03 21:49 ` vries at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2024-12-03 21:49 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=32388
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|--- |16.1
Status|NEW |RESOLVED
--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
Fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-03 21:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-25 8:12 [Bug python/32388] New: [gdb/python] Warn on setting python dont-write-bytecode/ignore-environment after python initialization vries at gcc dot gnu.org
2024-11-27 14:17 ` [Bug python/32388] " vries at gcc dot gnu.org
2024-12-03 21:48 ` cvs-commit at gcc dot gnu.org
2024-12-03 21:49 ` vries at gcc dot gnu.org
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).