Skip to content

bpo-11001: updated cookie docs #13086

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

Merged
merged 2 commits into from
May 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Doc/library/http.cookies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ in Cookie name (as :attr:`~Morsel.key`).
.. class:: SimpleCookie([input])

This class derives from :class:`BaseCookie` and overrides :meth:`value_decode`
and :meth:`value_encode` to be the identity and :func:`str` respectively.

and :meth:`value_encode`. SimpleCookie supports strings as cookie values.
When setting the value, SimpleCookie calls the builtin :func:`str()` to convert
the value to a string. Values received from HTTP are kept as strings.

.. seealso::

Expand All @@ -76,15 +77,16 @@ Cookie Objects

.. method:: BaseCookie.value_decode(val)

Return a decoded value from a string representation. Return value can be any
type. This method does nothing in :class:`BaseCookie` --- it exists so it can be
overridden.
Return a tuple ``(real_value, coded_value)`` from a string representation.
``real_value`` can be any type. This method does no decoding in
:class:`BaseCookie` --- it exists so it can be overridden.


.. method:: BaseCookie.value_encode(val)

Return an encoded value. *val* can be any type, but return value must be a
string. This method does nothing in :class:`BaseCookie` --- it exists so it can
Return a tuple ``(real_value, coded_value)``. *val* can be any type, but
``coded_value`` will always be converted to a string.
This method does no encoding in :class:`BaseCookie` --- it exists so it can
be overridden.

In general, it should be the case that :meth:`value_encode` and
Expand Down