Skip to content

SimpleCookie throws AttributeError: 'str' object has no attribute 'items' #203

Open
@serac

Description

@serac

Interactive session demonstrating problem:

marvin@eiger:~$ python
Python 2.7.10 (default, Jul 13 2015, 12:05:58)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from future.backports.http.cookies import SimpleCookie
>>> kaka='JSESSIONID=189xm7lb936kjxt7bbwxqf1lb'
>>> cookie_object = SimpleCookie(kaka)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/future-0.15.2-py2.7.egg/future/backports/http/cookies.py", line 492, in __init__
    self.load(input)
  File "/usr/local/lib/python2.7/site-packages/future-0.15.2-py2.7.egg/future/backports/http/cookies.py", line 545, in load
    for key, value in rawdata.items():

The error is caused by the following isinstance check:

    if isinstance(rawdata, str):
        self.__parse_string(rawdata)
    else:
        # self.update() wouldn't call our custom __setitem__
        for key, value in rawdata.items():
            self[key] = value
    return

I have verified that replacing str with basestring fixes the problem, but I am totally at a loss as to why.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions