]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40094: CGIHTTPRequestHandler logs exit code (GH-19285)
authorVictor Stinner <vstinner@python.org>
Thu, 2 Apr 2020 01:42:05 +0000 (03:42 +0200)
committerGitHub <noreply@github.com>
Thu, 2 Apr 2020 01:42:05 +0000 (03:42 +0200)
CGIHTTPRequestHandler of http.server now logs the CGI script exit
code, rather than the CGI script exit status of os.waitpid().

For example, if the script is killed by signal 11, it now logs:
"CGI script exit code -11."

Lib/http/server.py
Misc/NEWS.d/next/Library/2020-04-02-01-13-28.bpo-40094.AeZ34K.rst [new file with mode: 0644]

index 2d74b95586cff48128fc6544c7e69c18dc6599fd..fa204fbc15e3d71ea19e01685d942fc1e8d99551 100644 (file)
@@ -1164,8 +1164,9 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
                 while select.select([self.rfile], [], [], 0)[0]:
                     if not self.rfile.read(1):
                         break
-                if sts:
-                    self.log_error("CGI script exit status %#x", sts)
+                exitcode = os.waitstatus_to_exitcode(sts)
+                if exitcode:
+                    self.log_error(f"CGI script exit code {exitcode}")
                 return
             # Child
             try:
diff --git a/Misc/NEWS.d/next/Library/2020-04-02-01-13-28.bpo-40094.AeZ34K.rst b/Misc/NEWS.d/next/Library/2020-04-02-01-13-28.bpo-40094.AeZ34K.rst
new file mode 100644 (file)
index 0000000..ba13d3c
--- /dev/null
@@ -0,0 +1,3 @@
+CGIHTTPRequestHandler of http.server now logs the CGI script exit code,
+rather than the CGI script exit status of os.waitpid(). For example, if the
+script is killed by signal 11, it now logs: "CGI script exit code -11."