From 6d04cae4210534002c2e6ac94d08c48f3d667646 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 12 Nov 2023 14:46:38 +0300 Subject: [PATCH] Fix(Py3): Work around an old bug in `urlopen` It passes an extra parameter `timeout` which `URLopener.open()` doesn't accept. --- Robots/bkmk_rurllib_py3.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Robots/bkmk_rurllib_py3.py b/Robots/bkmk_rurllib_py3.py index 796a6fc..aca07cd 100644 --- a/Robots/bkmk_rurllib_py3.py +++ b/Robots/bkmk_rurllib_py3.py @@ -11,6 +11,7 @@ __license__ = "GNU GPL" __all__ = ['robot_urllib_py3'] +import socket import sys import urllib.request @@ -53,6 +54,9 @@ class MyURLopener(urllib.request.URLopener): fp.close() raise IOError(('http error', errcode, errmsg, headers)) + def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): + return urllib.request.URLopener.open(self, fullurl, data) + urllib.request._opener = opener = MyURLopener() -- 2.39.5