You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using session.data_serializer=json produces the following error (full stack trace below):
TypeError: Object of type datetime is not JSON serializable
Details
The _expires attribute is set on a CookieSession to a datetime object here
When that cookie is serialized to json, an error is through as datetimes are not JSON serializable
This error seems to only occur after the 2nd time a cookie is .save()d: only after the first .save() the _expires attribute is set to a datetime on the cookie and then subsequent uses of the cookie fail at serialization.
It seems this is specifc to (or at least sensitive to) the session.cookie_expires parameter.
When set to False (or None since None seems to default to False) or a timedelta we get a JSON serialization error.
However when set to session.cookie_expires = true the error does not occur.
$ python repro.py
failed for: cookie_expires=False:
Object of type datetime is not JSON serializable
failed for: cookie_expires=0:00:10:
Object of type datetime is not JSON serializable
Overview
Using
session.data_serializer=json
produces the following error (full stack trace below):Details
_expires
attribute is set on aCookieSession
to adatetime
object herejson
, an error is through asdatetime
s are not JSON serializable.save()
d: only after the first.save()
the_expires
attribute is set to adatetime
on the cookie and then subsequent uses of the cookie fail at serialization.Reproducible Example
Test Case
Flask
localhost:5000
-> expect to load fine the first timeFull Stack Trace
The text was updated successfully, but these errors were encountered: