From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 13 Jan 2025 16:44:49 +0000 (+0100) Subject: [3.13] gh-128731: Explicitly close socket on error in robotparser.RobotFileParser... X-Git-Tag: v3.13.2~108 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a8686288366a6149a59d8ef66f9c44b608cda974;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-128731: Explicitly close socket on error in robotparser.RobotFileParser.read() (GH-128733) (GH-128755) (cherry picked from commit 5e65a1acc0b630397f1d190aed279114e6e99612) Co-authored-by: Serhiy Storchaka --- diff --git a/Lib/urllib/robotparser.py b/Lib/urllib/robotparser.py index c58565e39451..24ee198c355f 100644 --- a/Lib/urllib/robotparser.py +++ b/Lib/urllib/robotparser.py @@ -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())