On 20 Apr 2023, at 16:52, Gustaf Waldemarson <gustaf.waldemarson@gmail.com> wrote:


> Oh i see you read all the files.
> Usually you need to stop looking once you find an rc file.

I guess that really depends on the program, but since pdb is modelled on
gdb, I figured it made sense to do something similar :)

Turns out the gdbinit behaviour is complex.
From https://sourceware.org/gdb/onlinedocs/gdb/Initialization-Files.html#Initialization-Files

2.1.4.3 Home directory initialization file

After loading the system wide initialization files GDB will look for an initialization file in the users home directory2. There are a number of locations that GDB will search in the home directory, these locations are searched in order and GDB will load the first file that it finds, and subsequent locations will not be checked.

On non-Apple hosts the locations searched are:

$XDG_CONFIG_HOME/gdb/gdbinit
$HOME/.config/gdb/gdbinit
$HOME/.gdbinit

Then ./.gdbinit is loaded if . Is not ~/

And you need different logic for macOS.


Anyways, I'll prep a pull-request for the cpython repo, should be interesting
to see what comes up.

Best regards,
Gustaf

Den tors 20 apr. 2023 kl 17:05 skrev Barry <barry@barrys-emacs.org>:


On 20 Apr 2023, at 14:24, Gustaf Waldemarson <gustaf.waldemarson@gmail.com> wrote:


Interesting, are you both sure ./.pdbrc should be the first file? I was expecting
the order to always go from "most general" to "most specific", i.e.,
"system" -> "home" -> "current". This way, it would be straightforward
to have general configuration in a "system"/"home" configuration which can
be overwritten in a more specialized one ("current").

Oh i see you read all the files.
Usually you need to stop looking once you find an rc file.

Barry


Coincidentally, this is also the order GDB is using:

Any particular reason you guys prefer a different order?

> Not your job, but I bet you get "are there other stdlib applications
> that would benefit from this change?" as feedback.  Eg, IDLE.

Probably, but lets start the discussion somewhere!

Best regards,
Gustaf


Den ons 19 apr. 2023 kl 17:11 skrev turnbull <turnbull@sk.tsukuba.ac.jp>:
I apologize for the top-post and awkward trimming, my employer just
switched to o365 and won't accomodate my existing mail client so I'm
stuck with a crappy webmail client on this address. :-p

I agree with Barry on both points: seems like a good idea, but the
search priority should be
./.pdbrc first.

Not your job, but I bet you get "are there other stdlib applications
that would benefit from this change?" as feedback.  Eg, IDLE.

2023-04-19 02:50 に Barry さんは書きました:

>>    +            for rcFileName in ('${XDG_CONFIG_HOME}/python/pdbrc',
>>    +                               '~/.config/python/pdbrc',
>>    +                               '~/.pdbrc',
>>    +                               '.pdbrc'):
> I would expect .pdbrc to be first.
>
>>    +                rcPath =
>> os.path.expanduser(os.path.expandvars(rcFileName))
>>    +                try:
>>    +                    with open(rcPath, encoding='utf-8') as rcFile:
>>    +                        self.rcLines.extend(rcFile)
>>    +                except OSError:
>>    +                    pass
>>
>>             self.commands = {} # associates a command list to
>> breakpoint numbers
>>             self.commands_doprompt = {} # for each bp num, tells if
>> the prompt
>
> Try raising a python bug and a PR with this code in it.
> Seems reasonable change to support.
>
> Barry