Description: Close the addinfourl wrapper in test_stream test_python_issue_20007_b leaves the addinfourl it wraps around the fake HTTPResponse unclosed, so the socket is only released when the object is garbage collected, emitting a ResourceWarning at some arbitrary later point in the run. Close it explicitly instead. . This replaces 0004-Ignore-ResourceWarning-with-Python-3.14.patch, which handled the same leak from the other end by suppressing ResourceWarning for every tokenizer test. Neither patch is needed to build against pytest 9.1 and Python 3.14 -- the suite passes with both removed -- but the leak itself is real and upstream has a fix pending. Author: Dale Richards Origin: upstream, https://github.com/html5lib/html5lib-python/pull/591 Forwarded: https://github.com/html5lib/html5lib-python/pull/591 Last-Update: 2026-09-18 --- a/html5lib/tests/test_stream.py +++ b/html5lib/tests/test_stream.py @@ -208,9 +208,9 @@ def test_python_issue_20007_b(): source = http.client.HTTPResponse(FakeSocket()) source.begin() - wrapped = urllib.response.addinfourl(source, source.msg, "http://example.com") - stream = HTMLInputStream(wrapped) - assert stream.charsUntil(" ") == "Text" + with urllib.response.addinfourl(source, source.msg, "http://example.com") as wrapped: + stream = HTMLInputStream(wrapped) + assert stream.charsUntil(" ") == "Text" @pytest.mark.parametrize("inp,num",