Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set cookie incorrectly handles timedelta expires argument #166

Closed
luhn opened this issue Nov 4, 2014 · 2 comments
Closed

Set cookie incorrectly handles timedelta expires argument #166

luhn opened this issue Nov 4, 2014 · 2 comments

Comments

@luhn
Copy link

@luhn 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 response.py:

        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.

@bertjwregeer
Copy link
Member

@bertjwregeer bertjwregeer commented Nov 7, 2014

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.

@bertjwregeer
Copy link
Member

@bertjwregeer bertjwregeer commented Nov 9, 2014

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
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants