]> git.phdru.name Git - bookmarks_db.git/blobdiff - Robots/bkmk_rurllib.py
Fix(Py3): Open files in text mode
[bookmarks_db.git] / Robots / bkmk_rurllib.py
index f71a8d2bb55d22f5f823e44fae765abc800c7e32..93dbae8c62378297ed3fd013f3a56c129cbfb954 100644 (file)
@@ -11,9 +11,7 @@ __license__ = "GNU GPL"
 __all__ = ['robot_urllib']
 
 
-import os
 import sys
-import time
 import urllib
 
 from Robots.bkmk_robot_base import robot_base, get_error
@@ -29,9 +27,9 @@ class RedirectException(Exception):
 class MyURLopener(urllib.URLopener):
     # Error 301 -- relocated (permanently)
     def http_error_301(self, url, fp, errcode, errmsg, headers, data=None):
-        if headers.has_key('location'):
+        if 'location' in headers:
             newurl = headers['location']
-        elif headers.has_key('uri'):
+        elif 'uri' in headers:
             newurl = headers['uri']
         else:
             newurl = "Nowhere"
@@ -51,7 +49,7 @@ class MyURLopener(urllib.URLopener):
 
     def http_error_default(self, url, fp, errcode, errmsg, headers):
         if fp:
-            void = fp.read()
+            fp.read()
             fp.close()
         raise IOError(('http error', errcode, errmsg, headers))
 
@@ -104,7 +102,7 @@ class robot_urllib(robot_base):
                     # Remove Accept-Charset
                     del urllib._urlopener.addheaders[-1]
 
-            infile = open(fname, 'rb')
+            infile = open(fname, 'rt')
             content = infile.read()
             infile.close()