]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-128731: Explicitly close socket on error in robotparser.RobotFileParser...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 12 Jan 2025 13:34:24 +0000 (14:34 +0100)
committerGitHub <noreply@github.com>
Sun, 12 Jan 2025 13:34:24 +0000 (13:34 +0000)
(cherry picked from commit 5e65a1acc0b630397f1d190aed279114e6e99612)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/urllib/robotparser.py

index c58565e39451461f03dc7d9fb652554c96615f00..24ee198c355f56cb69c764a34430f25cd1717c0e 100644 (file)
@@ -65,6 +65,7 @@ class RobotFileParser:
                 self.disallow_all = True
             elif err.code >= 400 and err.code < 500:
                 self.allow_all = True
+            err.close()
         else:
             raw = f.read()
             self.parse(raw.decode("utf-8").splitlines())