]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-124703: Set return code to 1 when aborting process from pdb (#133013)
authorTian Gao <gaogaotiantian@hotmail.com>
Sat, 26 Apr 2025 22:43:23 +0000 (15:43 -0700)
committerGitHub <noreply@github.com>
Sat, 26 Apr 2025 22:43:23 +0000 (18:43 -0400)
Lib/pdb.py
Lib/test/test_pdb.py
Misc/NEWS.d/next/Library/2025-04-26-15-43-23.gh-issue-124703.jc5auS.rst [new file with mode: 0644]

index 380c6a56db72e57a3d2e41f8e0daed1531221f6a..5ade628e2d5d236beda370227486573e0e014c7f 100644 (file)
@@ -1834,7 +1834,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
                     reply = 'y'
                     self.message('')
                 if reply == 'y' or reply == '':
-                    sys.exit(0)
+                    sys.exit(1)
                 elif reply.lower() == 'n':
                     return
 
index 60a41becea4ca15b2731074b851e70a9dd67c290..741b5ab92856b7f6347ae63345bdc50223788be6 100644 (file)
@@ -4453,7 +4453,7 @@ class PdbTestInline(unittest.TestCase):
             y
         """
 
-        stdout, stderr = self._run_script(script, commands)
+        stdout, stderr = self._run_script(script, commands, expected_returncode=1)
         self.assertIn("2", stdout)
         self.assertIn("Quit anyway", stdout)
         # Closing stdin will quit the debugger anyway so we need to confirm
@@ -4483,7 +4483,7 @@ class PdbTestInline(unittest.TestCase):
             y
         """
 
-        stdout, stderr = self._run_script(script, commands)
+        stdout, stderr = self._run_script(script, commands, expected_returncode=1)
         # Normal exit should not print anything to stderr
         self.assertEqual(stderr, "")
         # The quit prompt should be printed exactly once
diff --git a/Misc/NEWS.d/next/Library/2025-04-26-15-43-23.gh-issue-124703.jc5auS.rst b/Misc/NEWS.d/next/Library/2025-04-26-15-43-23.gh-issue-124703.jc5auS.rst
new file mode 100644 (file)
index 0000000..54603dd
--- /dev/null
@@ -0,0 +1 @@
+Set return code to ``1`` when aborting process from :mod:`pdb`.