8000 bpo-11001: updated cookie docs (GH-13086) · lisroach/cpython@91cc01f · GitHub
[go: up one dir, main page]

Skip to content

Commit 91cc01f

Browse files
Julsymiss-islington
authored andcommitted
bpo-11001: updated cookie docs (pythonGH-13086)
Used **spookylukey**'s patch from 2011-01-24 https://bugs.python.org/issue11001
1 parent 64aa6d2 commit 91cc01f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Doc/library/http.cookies.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ in Cookie name (as :attr:`~Morsel.key`).
5555
.. class:: SimpleCookie([input])
5656

5757
This class derives from :class:`BaseCookie` and overrides :meth:`value_decode`
58-
and :meth:`value_encode` to be the identity and :func:`str` respectively.
59-
58+
and :meth:`value_encode`. SimpleCookie supports strings as cookie values.
59+
When setting the value, SimpleCookie calls the builtin :func:`str()` to convert
60+
the value to a string. Values received from HTTP are kept as strings.
6061

6162
.. seealso::
6263

@@ -76,15 +77,16 @@ Cookie Objects
7677

7778
.. method:: BaseCookie.value_decode(val)
7879

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

8384

8485
.. method:: BaseCookie.value_encode(val)
8586

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

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

0 commit comments

Comments
 (0)
0