Skip to content

Conversation

@saucoide
Copy link
Contributor

@saucoide saucoide commented Jul 19, 2025

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

Lib/pdb.py Outdated
except OSError:
pass
if os.path.join(
os.path.abspath(os.curdir), ".pdbrc"
Copy link
Member

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?

Copy link
Contributor Author

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 ?

rc_path = os.path.join(cwd, ".pdbrc")
with open(rc_path, "w") as f:
f.write("invalid")
self.assertEqual(pdb.Pdb().rcLines[0], "invalid")
Copy link
Member

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.

Copy link
Contributor Author

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

self.assertEqual(pdb.Pdb().rcLines[0], "invalid")
self.assertEqual(len(pdb.Pdb().rcLines), 1)

def test_readrc_home_twice(self):
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@saucoide
Copy link
Contributor Author

@gaogaotiantian could you take a look at the latest version? thanks!

@encukou
Copy link
Member

encukou commented Dec 18, 2025

This looks good to me. @gaogaotiantian, do you want to take another look?

I can see possible ways to improve it, but nothing major:

  • Only call os.path.expanduser once & save the result
  • Perhaps use os.path.samefile instead of comparing paths

Copy link
Member

@gaogaotiantian gaogaotiantian left a comment

Choose a reason for hiding this comment

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

Oh we need a news entry :)

The fix is clean, test is well written. Sorry I forgot about this, thanks for the ping @encukou ! @saucoide I was on a world trip on August so missed a lot of pings :(

@bedevere-app
Copy link

bedevere-app bot commented Dec 19, 2025

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@saucoide
Copy link
Contributor Author

@gaogaotiantian added the news item & applied petr's suggestion to reuse the expanded result

@gaogaotiantian
Copy link
Member

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 rcFile to rcfile because we are using variables like home_rcfile now.

@saucoide
Copy link
Contributor Author

@gaogaotiantian done

@gaogaotiantian gaogaotiantian merged commit 09044dd into python:main Dec 21, 2025
49 of 50 checks passed
cocolato pushed a commit to cocolato/cpython that referenced this pull request Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants