mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-20523: pdb searches for .pdbrc in ~ instead of $HOME (GH-11847)
Previously pdb checked the $HOME environmental variable to find the user .pdbrc. If $HOME is not set, the user .pdbrc would not be found. Change pdb to use `os.path.expanduser('~')` to determine the user's home directory. Thus, if $HOME is not set (as in tox or on Windows), os.path.expanduser('~') falls back on other techniques for locating the user's home directory. This follows pip's implementation for loading .piprc. Co-authored-by: Dan Lidral-Porter <dlp@aperiodic.org>
This commit is contained in:
parent
8fbece135d
commit
7ea9a85f13
3 changed files with 21 additions and 8 deletions
14
Lib/pdb.py
14
Lib/pdb.py
|
@ -160,16 +160,14 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
|||
self.allow_kbdint = False
|
||||
self.nosigint = nosigint
|
||||
|
||||
# Read $HOME/.pdbrc and ./.pdbrc
|
||||
# Read ~/.pdbrc and ./.pdbrc
|
||||
self.rcLines = []
|
||||
if readrc:
|
||||
if 'HOME' in os.environ:
|
||||
envHome = os.environ['HOME']
|
||||
try:
|
||||
with open(os.path.join(envHome, ".pdbrc")) as rcFile:
|
||||
self.rcLines.extend(rcFile)
|
||||
except OSError:
|
||||
pass
|
||||
try:
|
||||
with open(os.path.expanduser('~/.pdbrc')) as rcFile:
|
||||
self.rcLines.extend(rcFile)
|
||||
except OSError:
|
||||
pass
|
||||
try:
|
||||
with open(".pdbrc") as rcFile:
|
||||
self.rcLines.extend(rcFile)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue