[3.10] bpo-34266: [pdb] handle ValueError from shlex.split() (GH-26656) (GH-27006)
(cherry picked from commit d968a638fcbf9030c999cfacd4c9bf0656e779c4)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 3bece76..cdd427a 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -1800,6 +1800,21 @@ def test_errors_in_command(self):
'(Pdb) ',
])
+ def test_issue34266(self):
+ '''do_run handles exceptions from parsing its arg'''
+ def check(bad_arg, msg):
+ commands = "\n".join([
+ f'run {bad_arg}',
+ 'q',
+ ])
+ stdout, _ = self.run_pdb_script('pass', commands + '\n')
+ self.assertEqual(stdout.splitlines()[1:], [
+ '-> pass',
+ f'(Pdb) *** Cannot run {bad_arg}: {msg}',
+ '(Pdb) ',
+ ])
+ check('\\', 'No escaped character')
+ check('"', 'No closing quotation')
def test_issue42384(self):
'''When running `python foo.py` sys.path[0] is an absolute path. `python -m pdb foo.py` should behave the same'''