Skip to content

Set cookie incorrectly handles timedelta expires argument #166

Description

@luhn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions