Skip to content

Commit 24f5cac

Browse files
pablogsalvstinner
authored andcommitted
bpo-38962: Fix reference leak in test_httpservers (GH-17454)
1 parent edd5b38 commit 24f5cac

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Lib/test/test_httpservers.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -807,11 +807,15 @@ def test_query_with_continuous_slashes(self):
807807
(res.read(), res.getheader('Content-type'), res.status))
808808

809809
def test_cgi_path_in_sub_directories(self):
810-
CGIHTTPRequestHandler.cgi_directories.append('/sub/dir/cgi-bin')
811-
res = self.request('/sub/dir/cgi-bin/file5.py')
812-
self.assertEqual(
813-
(b'Hello World' + self.linesep, 'text/html', HTTPStatus.OK),
814-
(res.read(), res.getheader('Content-type'), res.status))
810+
try:
811+
CGIHTTPRequestHandler.cgi_directories.append('/sub/dir/cgi-bin')
812+
res = self.request('/sub/dir/cgi-bin/file5.py')
813+
self.assertEqual(
814+
(b'Hello World' + self.linesep, 'text/html', HTTPStatus.OK),
815+
(res.read(), res.getheader('Content-type'), res.status))
816+
finally:
817+
CGIHTTPRequestHandler.cgi_directories.remove('/sub/dir/cgi-bin')
818+
815819

816820

817821
class SocketlessRequestHandler(SimpleHTTPRequestHandler):

0 commit comments

Comments
 (0)