Skip to content

Commit 5e65a1a

Browse files
gh-128731: Fix ResourceWarning in robotparser.RobotFileParser.read() (GH-128733)
1 parent f6c61bf commit 5e65a1a

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)