]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-128731: Fix ResourceWarning in robotparser.RobotFileParser.read() (GH-128733)
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 12 Jan 2025 13:14:46 +0000 (15:14 +0200)
committerGitHub <noreply@github.com>
Sun, 12 Jan 2025 13:14:46 +0000 (15:14 +0200)
Lib/urllib/robotparser.py
Misc/NEWS.d/next/Library/2025-01-11-13-40-12.gh-issue-128731.qpKlai.rst [new file with mode: 0644]

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())
diff --git a/Misc/NEWS.d/next/Library/2025-01-11-13-40-12.gh-issue-128731.qpKlai.rst b/Misc/NEWS.d/next/Library/2025-01-11-13-40-12.gh-issue-128731.qpKlai.rst
new file mode 100644 (file)
index 0000000..b23499c
--- /dev/null
@@ -0,0 +1 @@
+Fix :exc:`ResourceWarning` in :meth:`urllib.robotparser.RobotFileParser.read`.