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 response.py:
TypeError: unsupported operand type(s) for -: 'datetime.timedelta' and 'datetime.datetime'
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.
Merge remote-tracking branch 'origin/pr/188'
Fixes #166, #171