[PATCH 7/7] gdb: startup commands to control Python extension language

Tom de Vries tdevries@suse.de
Thu Apr 29 10:08:50 GMT 2021


On 4/29/21 11:46 AM, Andrew Burgess wrote:
> * 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.
> 

Hi Andrew,

LGTM, I just wonder if something like this is not more clear, that is,
reformulate in terms of already explained option value off, rather than
verbosely repeating the off behaviour.  So, something like this:
...
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 auto has the same behaviour as
off.
...

But then again, this may be a bad idea, I'm not sure.

Thanks,
- Tom


More information about the Gdb-patches mailing list