]> git.phdru.name Git - bookmarks_db.git/commitdiff
Fix(Py3): Work around an old bug in `urlopen`
authorOleg Broytman <phd@phdru.name>
Sun, 12 Nov 2023 11:46:38 +0000 (14:46 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 12 Nov 2023 19:21:09 +0000 (22:21 +0300)
It passes an extra parameter `timeout`
which `URLopener.open()` doesn't accept.

Robots/bkmk_rurllib_py3.py

index 796a6fca3425bfb8d91d035968d02be246605bb3..aca07cd86a09d21845597a3d84f76f10c98a2a48 100644 (file)
@@ -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()