From 9d693b57caf39035025f83fc11af3c7934a9741f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Thu, 14 Feb 2019 11:41:25 +0100 Subject: [PATCH] bpo-20523: pdb.Pdb can read the global ~/.pdbrc file on Windows 7 --- Lib/pdb.py | 15 ++++++++------- .../2019-02-14-11-39-44.bpo-20523.yRS9BA.rst | 2 ++ 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2019-02-14-11-39-44.bpo-20523.yRS9BA.rst 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