[3.13] gh-128731: Explicitly close socket on error in robotparser.RobotFileParser.read() (GH-128733) (GH-128755)

(cherry picked from commit 5e65a1acc0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-01-13 17:44:49 +01:00 committed by GitHub
parent b1065767b4
commit a868628836
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View 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())