Patch #1478993: take advantage of BaseException/Exception split in cookielib

This commit is contained in:
Georg Brandl 2006-05-08 17:48:01 +00:00
parent b5f2e5cc50
commit e854e765f4
3 changed files with 35 additions and 29 deletions

View file

@ -12,9 +12,10 @@ libwww-perl, I hope.
"""
import time, re, logging
from cookielib import (reraise_unmasked_exceptions, FileCookieJar, LoadError,
Cookie, MISSING_FILENAME_TEXT, join_header_words, split_header_words,
iso2time, time2isoz)
from cookielib import (_warn_unhandled_exception, FileCookieJar, LoadError,
Cookie, MISSING_FILENAME_TEXT,
join_header_words, split_header_words,
iso2time, time2isoz)
def lwp_cookie_str(cookie):
"""Return string representation of Cookie in an the LWP cookie file format.
@ -92,7 +93,8 @@ class LWPCookieJar(FileCookieJar):
def _really_load(self, f, filename, ignore_discard, ignore_expires):
magic = f.readline()
if not re.search(self.magic_re, magic):
msg = "%s does not seem to contain cookies" % filename
msg = ("%r does not look like a Set-Cookie3 (LWP) format "
"file" % filename)
raise LoadError(msg)
now = time.time()
@ -159,6 +161,10 @@ class LWPCookieJar(FileCookieJar):
if not ignore_expires and c.is_expired(now):
continue
self.set_cookie(c)
except:
reraise_unmasked_exceptions((IOError,))
raise LoadError("invalid Set-Cookie3 format file %s" % filename)
except IOError:
raise
except Exception:
_warn_unhandled_exception()
raise LoadError("invalid Set-Cookie3 format file %r: %r" %
(filename, line))