Skip to content

bpo-20523: pdb.Pdb can read the global ~/.pdbrc file on Windows 7 #11855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Copy link
Contributor

@augustogoulart augustogoulart Feb 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just me being picky about comments, so use (or not) the following at your will:

1 - Although this has been vastly done in CPython, I'm personally against including the issue number (bpo-20523) at the code changes. This practice pollutes the de code and thinking forward, I wouldn't like to see a million bpo's in the source code ten years from now.

2 - The second line use os.path.expanduser() is redundant. A good comment should tell why that change is necessary, and not how you are accomplishing that. Your code should be readable enough for anyone to figure out the hows. Which in this case, it's already readable enough.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@augustogoulart

  1. we have 431 "bpo-XYZ: " in the code of CPython.
  2. I explain the reason of os.path.expanduser, because $HOME does not exist on Windows 7.

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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``pdb.Pdb`` suppors the ~/.pdbrc on Windows 7. Contributed by Stéphane
Wirtel