-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
gh-80744: pdb: do not read .pdbrc twice when in $HOME #12731
base: main
Are you sure you want to change the base?
Conversation
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.
Perhaps add a test case for this? Please add a NEWS entry since this is change in behavior.
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 56d8232495..bc10ff3b91 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -1337,6 +1337,33 @@ class PdbTestCase(unittest.TestCase):
if save_home is not None:
os.environ['HOME'] = save_home
+ def test_readrc_home_twice(self):
+ script = textwrap.dedent("""
+ import pdb; pdb.Pdb(readrc=True).set_trace()
+
+ print('hello')
+ """)
+
+ with support.temp_cwd() as cur_dir:
+ with patch.dict(os.environ, {'HOME': cur_dir}):
+ with open('.pdbrc', 'w') as f:
+ f.write("invalid\n")
+
+ with open('main.py', 'w') as f:
+ f.write(script)
+
+ cmd = [sys.executable, 'main.py']
+ proc = subprocess.Popen(
+ cmd,
+ stdout=subprocess.PIPE,
+ stdin=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
+ with proc:
+ stdout, stderr = proc.communicate(b'q\n')
+ output = stdout.decode()
+ self.assertEqual(output.count('NameError'), 1)
+
def test_header(self):
stdout = StringIO()
header = 'Nobody expects... blah, blah, blah'
Test without patch :
➜ cpython git:(master) ✗ git checkout master Lib/pdb.py
➜ cpython git:(master) ✗ ./python.exe -m test --fail-env-changed -uall test_pdb
Run tests sequentially
0:00:00 load avg: 3.10 [1/1] test_pdb
test test_pdb failed -- Traceback (most recent call last):
File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/test/test_pdb.py", line 1365, in test_readrc_home_twice
self.assertEqual(output.count('NameError'), 1)
AssertionError: 2 != 1
test_pdb failed
== Tests result: FAILURE ==
1 test failed:
test_pdb
Total duration: 3 sec 249 ms
Tests result: FAILURE
Test with patch :
➜ cpython git:(master) ✗ git checkout pr_12731 Lib/pdb.py
➜ cpython git:(master) ✗ ./python.exe -m test --fail-env-changed -uall test_pdb
Run tests sequentially
0:00:00 load avg: 2.93 [1/1] test_pdb
== Tests result: SUCCESS ==
1 test OK.
Total duration: 3 sec 226 ms
Tests result: SUCCESS
@tirkarthi |
I am not sure I have the required access to push to a PR or maybe I am missing something in workflow. Feel free to use the test as part of next commit as needed 👍 |
@@ -162,18 +162,18 @@ def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None, | |||
# Read $HOME/.pdbrc and ./.pdbrc | |||
self.rcLines = [] | |||
if readrc: | |||
readrcFiles = [] |
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.
Small neat: please use name_with_underscores
instead of camelCase
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.
@asvetlov
I've tried to keep the style of the other vars there.
Can change it, but want to make sure it is really wanted.
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.
self.rcLines
exists starting from 2001.
Too late to change the name, it is a part of public API for good or for bad.
But for new variables better to follow PEP 8 style.
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 |
@blueyed is this abandoned? |
https://bugs.python.org/issue36563