diff --git a/Lib/pdb.py b/Lib/pdb.py index 60bdb7675c8131..707685d8ef5bde 100755 --- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -162,13 +162,14 @@ def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None, # Read $HOME/.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: + # bpo-20523: $HOME does not exist on Windows 7, + # use os.path.expanduser() + 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) diff --git a/Misc/NEWS.d/next/Library/2019-02-14-11-39-44.bpo-20523.yRS9BA.rst b/Misc/NEWS.d/next/Library/2019-02-14-11-39-44.bpo-20523.yRS9BA.rst new file mode 100644 index 00000000000000..7b89cfd45316e8 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-02-14-11-39-44.bpo-20523.yRS9BA.rst @@ -0,0 +1,2 @@ +``pdb.Pdb`` suppors the ~/.pdbrc on Windows 7. Contributed by Stéphane +Wirtel