Skip to content

Commit 6e1cd7e

Browse files
serhiy-storchakamiss-islington
authored andcommitted
pythongh-128731: Fix ResourceWarning in robotparser.RobotFileParser.read() (pythonGH-128733)
(cherry picked from commit 5e65a1a) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 6116e1b commit 6e1cd7e

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

Lib/urllib/robotparser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def read(self):
6565
self.disallow_all = True
6666
elif err.code >= 400 and err.code < 500:
6767
self.allow_all = True
68+
err.close()
6869
else:
6970
raw = f.read()
7071
self.parse(raw.decode("utf-8").splitlines())
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix :exc:`ResourceWarning` in :meth:`urllib.robotparser.RobotFileParser.read`.

0 commit comments

Comments
 (0)