This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jdennis
Recipients jdennis
Date 2012-12-04.20:50:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
There are multiple problems with Some of the issues are covered in which is still open (after 4.5 years).

In all honesty the API and the implementation are not great perhaps the best thing would be to remove it from the core libraries, however you can't remove a core library. There is is which is pretty good however is tightly coupled to urllib2 and if you're not using urllib2 you can't use so you're stuck using which means the best thing is to get the bugs in fixed.

Of the problems illustrated in the attached unittest ( the absolute must fix issues are the inability to parse an Expires attribute and the impossibility of testing the HttpOnly & Secure flags for a truth value after parsing. Those are critical because it makes using impossible. The other errors would be nice to get fixed, but not as critical. Next in importance would be respecting the truth value when setting the HttpOnly & Secure flags. Failing to detect an improperly formatted cookie when parsing is the least important because hopefully you won't have improperly formatted cookies (unfortunately a weak assumption)

Note: the HttpOnly and Secure issues are symmetrical, they both suffer the same problems because they're both boolean flags whose True value is asserted by the flag's presence and it's False value by it's absence.
Cookie parsing problems:

* Cannot read a properly formatted Expires attribute (see also issue 3073)

* Impossible to determine state of HttpOnly boolean flag after parsing

* Impossible to determine state of Secure boolean flag after parsing

* Fails to raise any errors when parsing invalid cookie strings

Cookie creation/initialization problems:

* Setting HttpOnly flag to a value which evaluates to False results in the flag being set to True (there is no check whatsoever on the value).

* Setting Secure flag to a value which evaluates to False results in the flag being set to True (there is no check whatsoever on the value).

Attached is a unittest illustrating the problems (more details are in the unittest).

Ran 13 tests in 0.003s

FAILED (failures=9)
Date User Action Args
2012-12-04 20:50:24jdennissetrecipients: + jdennis
2012-12-04 20:50:24jdennissetmessageid: <>
2012-12-04 20:50:24jdennislinkissue16611 messages
2012-12-04 20:50:24jdenniscreate