From: Oleg Broytman Date: Fri, 4 Jul 2014 19:36:34 +0000 (+0400) Subject: Remove Accept-Charset even in case of error X-Git-Tag: v4.6.0~20 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=44cc53578e4a5bd5122ecbcbfcf16000ed4e57fc;p=bookmarks_db.git Remove Accept-Charset even in case of error --- diff --git a/Robots/bkmk_rurllib.py b/Robots/bkmk_rurllib.py index efade79..ceaf67b 100644 --- a/Robots/bkmk_rurllib.py +++ b/Robots/bkmk_rurllib.py @@ -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()