Author DenNukem
Recipients DenNukem
Date 2008-09-21.18:30:23
SpamBayes Score 9.73134e-09
Marked as misclassified No
Message-id <1222021824.75.0.209543556591.issue3924@psf.upfronthosting.co.za>
In-reply-to
Content
PROBLEM:

Some sites (e.g. https://itunesconnect.apple.com) sends cookies where
version is "1" instead of 1. Cookielib chokes on it so none of the
cookies work after that.

PROBLEM CODE:
    def _cookie_from_cookie_tuple(self, tup, request):
...
        name, value, standard, rest = tup
...
        version = standard.get("version", None)
        if version is not None: version = int(version) << CRASH HERE!!!



WORKAROUND:

use my own cookie jar, e.g.:

class MyCookieJar(CookieJar):
    def _cookie_from_cookie_tuple(self, tup, request):
        name, value, standard, rest = tup
        standard["version"]= None
        CookieJar._cookie_from_cookie_tuple(self, tup, request)

REAL FIX:
do not assume that version is int, keep it as string if it does not
parse as int:

CRASH STACK:

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/cookielib.py:1577:
UserWarning: cookielib bug!
Traceback (most recent call last):
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/cookielib.py",
line 1575, in make_cookies
    parse_ns_headers(ns_hdrs), request)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/cookielib.py",
line 1532, in _cookies_from_attrs_set
    cookie = self._cookie_from_cookie_tuple(tup, request)
  File
"/Users/denis/Documents/svn2/tson/main/sales/src/download_sales.py",
line 28, in _cookie_from_cookie_tuple
    CookieJar._cookie_from_cookie_tuple(self, tup, request)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/cookielib.py",
line 1451, in _cookie_from_cookie_tuple
    if version is not None: version = int(version)
ValueError: invalid literal for int() with base 10: '"1"'

  _warn_unhandled_exception()
History
Date User Action Args
2008-09-21 18:30:25DenNukemsetrecipients: + DenNukem
2008-09-21 18:30:24DenNukemsetmessageid: <1222021824.75.0.209543556591.issue3924@psf.upfronthosting.co.za>
2008-09-21 18:30:24DenNukemlinkissue3924 messages
2008-09-21 18:30:23DenNukemcreate