bpo-20523: pdb searches for .pdbrc in ~ instead of $HOME#11847
bpo-20523: pdb searches for .pdbrc in ~ instead of $HOME#11847zooba merged 2 commits intopython:masterfrom
Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
|
This also solves a problem we encountered trying to launch pdb (via |
There was a problem hiding this comment.
why do you test with '~' ? normally, you won't get the tilde but the full path. I have an other PR but you can check with my code and fix yours. #11855
There was a problem hiding this comment.
envHome != '~' is true if expanduser succeeded in finding the full path.
There was a problem hiding this comment.
yep, but in which case can you have '~' ? never
There was a problem hiding this comment.
Your solution is cleaner. We took the approach of modifying the fewest lines.
There was a problem hiding this comment.
in fact, expanduser will replace ~ by the $HOME, $HOMEDRIVE, $HOMEPATH, etc... for Windows and unix-like, so normally, you won't get the ~. my approach is different because I wait for an exception and sometimes, an exception is better than a condition.
There was a problem hiding this comment.
You could have ~ if the expansion fails (e.g. if it can't find anything resembling a home directory): "If the expansion fails or if the path does not begin with a tilde, the path is returned unchanged."
There was a problem hiding this comment.
yep, it's possible.
- use python3 for the documentation (https://docs.python.org/3/library/os.path.html#os.path.expanduser)
- if you can't read the file you will get an exception, in this case, you will get OSError or Exception.
There was a problem hiding this comment.
Updated to use your cleaner solution
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 <[email protected]>
93cddbf to
75c7c58
Compare
| self.rcLines.extend(rcFile) | ||
| except OSError: | ||
| pass | ||
| try: |
There was a problem hiding this comment.
I think to an other solution:
for path in (os.path.expanduser('~/.pdbrc'), '.pdbrc'):
with contextlib.suppress(OSError), open(path) as rcFile:
self.rcLines.extend(rcFile) but I am not sure. need to test it.
|
Sorry for the slow reviews, but I'm happy with this, so it can go in for the next releases! |
|
I'm having trouble backporting to |
) 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 <[email protected]> (cherry picked from commit 7ea9a85) Co-authored-by: Timothy Hopper <[email protected]>
|
GH-15084 is a backport of this pull request to the 3.7 branch. |
) 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 <[email protected]> (cherry picked from commit 7ea9a85) Co-authored-by: Timothy Hopper <[email protected]>
|
GH-15085 is a backport of this pull request to the 3.8 branch. |
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 <[email protected]>
(cherry picked from commit 7ea9a85)
Co-authored-by: Timothy Hopper <[email protected]>
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 <[email protected]>
(cherry picked from commit 7ea9a85)
Co-authored-by: Timothy Hopper <[email protected]>
Tim and Dan were authors for 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 <[email protected]>
Tim and Dan were authors for pythonGH-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 <[email protected]>
Tim and Dan were authors for pythonGH-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 <[email protected]>
Tim and Dan were authors for pythonGH-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 determinethe 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 [email protected]
https://bugs.python.org/issue20523