]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40436: Fix code parsing gdb version (GH-19792)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 29 Apr 2020 15:30:46 +0000 (08:30 -0700)
committerGitHub <noreply@github.com>
Wed, 29 Apr 2020 15:30:46 +0000 (08:30 -0700)
test_gdb and test.pythoninfo now check gdb command exit code.
(cherry picked from commit ec9bea4a3766bd815148a27f61eb24e7dd459ac7)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/pythoninfo.py
Lib/test/test_gdb.py
Misc/NEWS.d/next/Tests/2020-04-29-16-08-24.bpo-40436.gDMnYl.rst [new file with mode: 0644]

index 9a9d26dca490cc724b6ff0848d5eca461449d26f..d16ad67cdc154d287a20e459f77297c8fe0c6f47 100644 (file)
@@ -340,6 +340,9 @@ def collect_gdb(info_add):
                                 stderr=subprocess.PIPE,
                                 universal_newlines=True)
         version = proc.communicate()[0]
+        if proc.returncode:
+            # ignore gdb failure: test_gdb will log the error
+            return
     except OSError:
         return
 
index 0131e4d0b0f72d41478cdc15eb0a4d45d5191047..fe603be2bbcd9d77e085383072ab51028c934c82 100644 (file)
@@ -18,12 +18,18 @@ from test.support import run_unittest, findfile, python_is_optimized
 
 def get_gdb_version():
     try:
-        proc = subprocess.Popen(["gdb", "-nx", "--version"],
+        cmd = ["gdb", "-nx", "--version"]
+        proc = subprocess.Popen(cmd,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,
                                 universal_newlines=True)
         with proc:
-            version = proc.communicate()[0]
+            version, stderr = proc.communicate()
+
+        if proc.returncode:
+            raise Exception(f"Command {' '.join(cmd)!r} failed "
+                            f"with exit code {proc.returncode}: "
+                            f"stdout={version!r} stderr={stderr!r}")
     except OSError:
         # This is what "no gdb" looks like.  There may, however, be other
         # errors that manifest this way too.
diff --git a/Misc/NEWS.d/next/Tests/2020-04-29-16-08-24.bpo-40436.gDMnYl.rst b/Misc/NEWS.d/next/Tests/2020-04-29-16-08-24.bpo-40436.gDMnYl.rst
new file mode 100644 (file)
index 0000000..0aee2c3
--- /dev/null
@@ -0,0 +1 @@
+test_gdb and test.pythoninfo now check gdb command exit code.