diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-03-15 09:52:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-15 09:52:00 (GMT) |
commit | abd079806d5f676410fbeaf1a7980f75f85833f7 (patch) | |
tree | 41956281ed6373790f830b7420e74a3d473fd54b /Lib | |
parent | 37514111be04e148181a1f6f96f3b65db775cce7 (diff) | |
download | cpython-abd079806d5f676410fbeaf1a7980f75f85833f7.zip cpython-abd079806d5f676410fbeaf1a7980f75f85833f7.tar.gz cpython-abd079806d5f676410fbeaf1a7980f75f85833f7.tar.bz2 |
[3.12] gh-90095: Ignore empty lines and comments in `.pdbrc` (GH-116834) (#116854)
gh-90095: Ignore empty lines and comments in `.pdbrc` (GH-116834)
(cherry picked from commit a50cf6c3d76b34e2ee9f92a248f1b0df24e407f6)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/pdb.py | 5 | ||||
-rw-r--r-- | Lib/test/test_pdb.py | 19 |
2 files changed, 23 insertions, 1 deletions
@@ -301,7 +301,10 @@ class Pdb(bdb.Bdb, cmd.Cmd): self.set_convenience_variable(self.curframe, '_frame', self.curframe) if self.rcLines: - self.cmdqueue = self.rcLines + self.cmdqueue = [ + line for line in self.rcLines + if line.strip() and not line.strip().startswith("#") + ] self.rcLines = [] # Override Bdb methods diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index db30412..5bdc5f2 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -2212,8 +2212,27 @@ def bœr(): """) stdout, stderr = self.run_pdb_script(script, 'q\n', pdbrc=pdbrc, remove_home=True) + self.assertNotIn("SyntaxError", stdout) self.assertIn("a+8=9", stdout) + def test_pdbrc_empty_line(self): + """Test that empty lines in .pdbrc are ignored.""" + + script = textwrap.dedent(""" + a = 1 + b = 2 + c = 3 + """) + + pdbrc = textwrap.dedent(""" + n + + """) + + stdout, stderr = self.run_pdb_script(script, 'q\n', pdbrc=pdbrc, remove_home=True) + self.assertIn("b = 2", stdout) + self.assertNotIn("c = 3", stdout) + def test_pdbrc_alias(self): script = textwrap.dedent(""" class A: |