From: Oleg Broytman Date: Sun, 12 Nov 2023 11:46:38 +0000 (+0300) Subject: Fix(Py3): Work around an old bug in `urlopen` X-Git-Tag: 5.0.0~50 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=6d04cae4210534002c2e6ac94d08c48f3d667646;p=bookmarks_db.git Fix(Py3): Work around an old bug in `urlopen` It passes an extra parameter `timeout` which `URLopener.open()` doesn't accept. --- 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()