]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-109096: Silence test_httpservers fork + threads DeprecationWarning on CGI...
authorGregory P. Smith <greg@krypto.org>
Sun, 17 Sep 2023 20:49:42 +0000 (13:49 -0700)
committerGitHub <noreply@github.com>
Sun, 17 Sep 2023 20:49:42 +0000 (22:49 +0200)
[3.12] gh-109096: Silence test_httpservers fork + threads DeprecationWarning on CGI support.

We're not fixing CGIHTTPRequestHandler as it is deprecated in 3.13 to go
away in 3.15.  This just removes noise from our test suite when warnings
are rightfully enabled.

If the long pre-existing fork+threading mix here ever causes anyone
deadlocks as is possible, disabling the test entirely on that platform
makes sense rather than attempting to fix
http.server.CGIHTTPRequestHandler or refactor to not use a threaded
server in the test.

Lib/test/test_httpservers.py

index cfd8a101dcc1c1e202acad4e528358390c6c22fb..15f944734c608ef3938316bd68a7b7f36d8d1557 100644 (file)
@@ -26,6 +26,7 @@ import time
 import datetime
 import threading
 from unittest import mock
+import warnings
 from io import BytesIO, StringIO
 
 import unittest
@@ -699,7 +700,11 @@ print("</pre>")
         "This test can't be run reliably as root (issue #13308).")
 class CGIHTTPServerTestCase(BaseTestCase):
     class request_handler(NoLogRequestHandler, CGIHTTPRequestHandler):
-        pass
+        def run_cgi(self):
+            # Silence the threading + fork DeprecationWarning this causes.
+            # gh-109096: This is deprecated in 3.13 to go away in 3.15.
+            with warnings.catch_warnings(action='ignore', category=DeprecationWarning):
+                return super().run_cgi()
 
     linesep = os.linesep.encode('ascii')