]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/python] Handle empty PYTHONDONTWRITEBYTECODE
authorTom de Vries <tdevries@suse.de>
Tue, 3 Dec 2024 21:54:23 +0000 (22:54 +0100)
committerTom de Vries <tdevries@suse.de>
Tue, 3 Dec 2024 21:54:23 +0000 (22:54 +0100)
commit922ab963e1c48c364b7f6363cb8e19f8a7175a20
treee5600a16d4131bd5a2950bb9dc5eb5692253d32b
parent1dc13c7e9f47718b51d8206e0b7cc8b244271ce4
[gdb/python] Handle empty PYTHONDONTWRITEBYTECODE

When using PYTHONDONTWRITEBYTECODE with an empty string we get:
...
$ PYTHONDONTWRITEBYTECODE= gdb -q -batch -ex "show python dont-write-bytecode"
Python's dont-write-bytecode setting is auto (currently on).
...

This is incorrect, it should be off.

The actual setting is correct, that was already fixed in commit 24d2cbc42cc
("set/show python dont-write-bytecode fixes"), in function
python_write_bytecode.

Fix this by:
- factoring out new function env_python_dont_write_bytecode out of
  python_write_bytecode, and
- using it in show_python_dont_write_bytecode.

Tested on x86_64-linux, using test-case gdb.python/py-startup-opt.exp and:
- PYTHONDONTWRITEBYTECODE=
- PYTHONDONTWRITEBYTECODE=1
- unset PYTHONDONTWRITEBYTECODE

Approved-By: Tom Tromey <tom@tromey.com>
PR python/32389
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32389
gdb/python/python.c
gdb/testsuite/gdb.python/py-startup-opt.exp