Set cookie incorrectly handles timedelta `expires` argument #166

luhn opened this Issue Nov 4, 2014 · 2 comments


None yet

2 participants

luhn commented Nov 4, 2014

Response.set_cookie is documented to have an expires argument that's a datetime.timedelta type. However, if max_age is None, a datetime.timedelta type will result in an error: TypeError: unsupported operand type(s) for -: 'datetime.timedelta' and 'datetime.datetime'. The guilty line is 778 in

        elif max_age is None and expires is not None:
            max_age = expires - datetime.utcnow()

This is WebOb 1.4.

A workaround is to use a datetime.datetime, which, although undocumented, works fine.


Hmm, I wonder if this issue is lurking in more places in the code. Will take a look tomorrow unless someone beats me to it.


This seems like it is a documentation issue. All tests for response.set_cookie use datetime. I updated the way the cookie handling is done in #172, this will fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment