Rebecka added the comment:
Akira is correct: using time.mktime to produce the expiration date for the
cookie is wrong (thank you very much for the pointers!).
Using e.g. http.cookiejar.http2time with a HTTP formatted date string gives a
correct time stamp (with which cookie.is_expired
Changes by Berker Peksag berker.pek...@gmail.com:
--
stage: needs patch - resolved
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22296
___
___
Rebecka added the comment:
I've checked and an updated test file for 3.4 shows the same behaviour in the
renamed module http.cookiejar.
Even though no standard exists I hope 3.4+ would be changed to simplify the
cookie handling, since there is a lot of hassle converting UTC times to local
Akira Li added the comment:
time.time() returns the current time in seconds since Epoch
it is neither local nor UTC time. It can be converted to both.
You can get local time using datetime.fromtimestamp(ts).
You can get UTC time using datetime.utcfromtimestamp(ts) or
to get an aware datetime
Antoine Pitrou added the comment:
Note the .timestamp() method will work correctly if the datetime object is
expressed in *local time*, which is not what Rebecka's code uses. Otherwise the
incantation is a bit more complex:
Akira Li added the comment:
timestamp() method works correctly for an aware datetime objects
as in my example (notice: timezone.utc in the code).
The issue is not that it is a manual computation,
the issue is that it is incorrect:
#XXX WRONG, DO NOT DO IT
Akira Li added the comment:
The last example assumes that time.gmtime(0) is 1970-01-01 00:00:00Z
(otherwise time.time() may return different timestamp)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22296
New submission from Rebecka:
The cookielib module uses time.time(), which produces a timestamp in the local
timezone (as read from the system time?), as the timestamp against which
expiration dates in cookies are compared.
However, typical usage of HTTP cookies would be specifying the
Terry J. Reedy added the comment:
If you have not, please check if this issue applies to 3.4, and post a 3.4
version of the test file.
In the absence of a standard, I am not sure if this is a bug, and even if we
call it such, whether 2.7 should be changed.
--
nosy: +terry.reedy