Skip to content

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants