]> git.phdru.name Git - bookmarks_db.git/commitdiff
Remove Accept-Charset even in case of error
authorOleg Broytman <phd@phdru.name>
Fri, 4 Jul 2014 19:36:34 +0000 (23:36 +0400)
committerOleg Broytman <phd@phdru.name>
Fri, 4 Jul 2014 19:36:34 +0000 (23:36 +0400)
Robots/bkmk_rurllib.py

index efade79a328d9c8724877cf1819b5b86570c66e3..ceaf67bd7218f5eb2b90203d2fdb0257d3b582e3 100644 (file)
@@ -81,9 +81,11 @@ class robot_urllib(robot_base):
 
          if accept_charset and bookmark.charset:
             urllib._urlopener.addheader('Accept-Charset', bookmark.charset)
-         fname, headers = urllib.urlretrieve(url)
-         if accept_charset and bookmark.charset:
-            del urllib._urlopener.addheaders[-1]
+         try:
+            fname, headers = urllib.urlretrieve(url)
+         finally:
+            if accept_charset and bookmark.charset:
+               del urllib._urlopener.addheaders[-1] # Remove Accept-Charset
 
          infile = open(fname, 'rb')
          content = infile.read()