-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
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
|
@gaogaotiantian could you take a look at the latest version? thanks! |
|
This looks good to me. @gaogaotiantian, do you want to take another look? I can see possible ways to improve it, but nothing major:
|
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.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
@gaogaotiantian added the news item & applied petr's suggestion to reuse the expanded result |
|
I have a final minor suggestion. We don't normally do cosmetic change but since we are working on this piece already, we might as well change |
cdf5b2d to
d3d79f8
Compare
|
@gaogaotiantian 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