-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-80744: do not read .pdbrc twice when cwd == $home #136816
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
base: main
Are you sure you want to change the base?
Conversation
Lib/pdb.py
Outdated
except OSError: | ||
pass | ||
if os.path.join( | ||
os.path.abspath(os.curdir), ".pdbrc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the equivalent check should be os.path.abspath(".pdbrc")
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaogaotiantian yeah i don't know what i was thinking there, updated
btw would it be ok to send a separate pr updating the pdb module & its tests to start using pathlib or preferring to keep os.path ?
Lib/test/test_pdb.py
Outdated
rc_path = os.path.join(cwd, ".pdbrc") | ||
with open(rc_path, "w") as f: | ||
f.write("invalid") | ||
self.assertEqual(pdb.Pdb().rcLines[0], "invalid") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should combine this line and the line below. Just check pdb.Pdb().rcLines
directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it self.assertEqual(pdb.Pdb().rcLines[-1], "invalid")
, this test is not patching a .pdbrc
at $HOME
so potentially there can be other lines first in rcLines, so now it only checks that the last one comes from the file written during the test
incidentally, i just found there are 5 other tests that fail if you do happen to have a non-empty .pdbrc at $home, it's ok in CI because there is none, but locally a few unrelated things fail when the file is present
Lib/test/test_pdb.py
Outdated
self.assertEqual(pdb.Pdb().rcLines[0], "invalid") | ||
self.assertEqual(len(pdb.Pdb().rcLines), 1) | ||
|
||
def test_readrc_home_twice(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename the function name to be something more descriptive. test_readrc_cwd_is_home
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
This is for #80744
There is a previous PR fixing this issue #12731 but it's been abandoned for years as the author is not active in github anymore