[Python-checkins] bpo-38962: Fix reference leak in test_httpservers (GH-17454)

Victor Stinner webhook-mailer at python.org
Wed Dec 4 04:29:18 EST 2019


https://github.com/python/cpython/commit/24f5cac7254177a4c9956d680c0a9b6dadd85c6f
commit: 24f5cac7254177a4c9956d680c0a9b6dadd85c6f
branch: master
author: Pablo Galindo <Pablogsal at gmail.com>
committer: Victor Stinner <vstinner at python.org>
date: 2019-12-04T10:29:10+01:00
summary:

bpo-38962: Fix reference leak in test_httpservers (GH-17454)

files:
M Lib/test/test_httpservers.py

diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 26da71e0b2701..c442f5571a868 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -807,11 +807,15 @@ def test_query_with_continuous_slashes(self):
             (res.read(), res.getheader('Content-type'), res.status))
 
     def test_cgi_path_in_sub_directories(self):
-        CGIHTTPRequestHandler.cgi_directories.append('/sub/dir/cgi-bin')
-        res = self.request('/sub/dir/cgi-bin/file5.py')
-        self.assertEqual(
-            (b'Hello World' + self.linesep, 'text/html', HTTPStatus.OK),
-            (res.read(), res.getheader('Content-type'), res.status))
+        try:
+            CGIHTTPRequestHandler.cgi_directories.append('/sub/dir/cgi-bin')
+            res = self.request('/sub/dir/cgi-bin/file5.py')
+            self.assertEqual(
+                (b'Hello World' + self.linesep, 'text/html', HTTPStatus.OK),
+                (res.read(), res.getheader('Content-type'), res.status))
+        finally:
+            CGIHTTPRequestHandler.cgi_directories.remove('/sub/dir/cgi-bin')
+
 
 
 class SocketlessRequestHandler(SimpleHTTPRequestHandler):



More information about the Python-checkins mailing list