diff options
Diffstat (limited to 'Lib/http/cookiejar.py')
| -rw-r--r-- | Lib/http/cookiejar.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py index cad6b3ac60..4466d2ece0 100644 --- a/Lib/http/cookiejar.py +++ b/Lib/http/cookiejar.py @@ -120,7 +120,7 @@ def time2netscape(t=None): dt = datetime.datetime.utcnow() else: dt = datetime.datetime.utcfromtimestamp(t) - return "%s %02d-%s-%04d %02d:%02d:%02d GMT" % ( + return "%s, %02d-%s-%04d %02d:%02d:%02d GMT" % ( DAYS[dt.weekday()], dt.day, MONTHS[dt.month-1], dt.year, dt.hour, dt.minute, dt.second) @@ -143,6 +143,10 @@ def offset_from_tz_string(tz): return offset def _str2time(day, mon, yr, hr, min, sec, tz): + yr = int(yr) + if yr > datetime.MAXYEAR: + return None + # translate month name to number # month numbers start with 1 (January) try: @@ -163,7 +167,6 @@ def _str2time(day, mon, yr, hr, min, sec, tz): if min is None: min = 0 if sec is None: sec = 0 - yr = int(yr) day = int(day) hr = int(hr) min = int(min) @@ -821,7 +824,7 @@ class Cookie: args.append("%s=%s" % (name, repr(attr))) args.append("rest=%s" % repr(self._rest)) args.append("rfc2109=%s" % repr(self.rfc2109)) - return "Cookie(%s)" % ", ".join(args) + return "%s(%s)" % (self.__class__.__name__, ", ".join(args)) class CookiePolicy: @@ -1838,7 +1841,7 @@ def lwp_cookie_str(cookie): class LWPCookieJar(FileCookieJar): """ The LWPCookieJar saves a sequence of "Set-Cookie3" lines. - "Set-Cookie3" is the format used by the libwww-perl libary, not known + "Set-Cookie3" is the format used by the libwww-perl library, not known to be compatible with any browser, but which is easy to read and doesn't lose information about RFC 2965 cookies. @@ -1999,7 +2002,6 @@ class MozillaCookieJar(FileCookieJar): magic = f.readline() if not self.magic_re.search(magic): - f.close() raise LoadError( "%r does not look like a Netscape format cookies file" % filename) |
