From 3b303d18b07e8fa8640ac2f6acba569770a58693 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 9 Dec 2023 23:56:28 +0200 Subject: [PATCH 1/3] Fix Sphinx warning in library/http.cookies.rst --- Doc/library/http.cookies.rst | 28 ++++++++++++++-------------- Doc/tools/.nitignore | 1 - 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst index a2c1eb00d8b33d..d2cb6da9b99237 100644 --- a/Doc/library/http.cookies.rst +++ b/Doc/library/http.cookies.rst @@ -54,8 +54,8 @@ 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`. SimpleCookie supports strings as cookie values. + This class derives from :class:`BaseCookie` and overrides :meth:`~BaseCookie.value_decode` + and :meth:`~BaseCookie.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. @@ -129,17 +129,17 @@ Morsel Objects Abstract a key/value pair, which has some :rfc:`2109` attributes. Morsels are dictionary-like objects, whose set of keys is constant --- the valid - :rfc:`2109` attributes, which are - - * ``expires`` - * ``path`` - * ``comment`` - * ``domain`` - * ``max-age`` - * ``secure`` - * ``version`` - * ``httponly`` - * ``samesite`` + :rfc:`2109` attributes, which are: + + * .. attribute:: expires + * .. attribute:: path + * .. attribute:: comment + * .. attribute:: domain + * .. attribute:: max-age + * .. attribute:: secure + * .. attribute:: version + * .. attribute:: httponly + * .. attribute:: samesite The attribute :attr:`httponly` specifies that the cookie is only transferred in HTTP requests, and is not accessible through JavaScript. This is intended @@ -152,7 +152,7 @@ Morsel Objects The keys are case-insensitive and their default value is ``''``. .. versionchanged:: 3.5 - :meth:`~Morsel.__eq__` now takes :attr:`~Morsel.key` and :attr:`~Morsel.value` + :meth:`!__eq__` now takes :attr:`~Morsel.key` and :attr:`~Morsel.value` into account. .. versionchanged:: 3.7 diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore index 5ef68cc089d436..73368223d90998 100644 --- a/Doc/tools/.nitignore +++ b/Doc/tools/.nitignore @@ -57,7 +57,6 @@ Doc/library/ftplib.rst Doc/library/functools.rst Doc/library/http.client.rst Doc/library/http.cookiejar.rst -Doc/library/http.cookies.rst Doc/library/http.server.rst Doc/library/importlib.rst Doc/library/inspect.rst From d9ec706ab445d7432a4bedb5ef9b7336da1b8922 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sun, 10 Dec 2023 00:05:24 +0200 Subject: [PATCH 2/3] MSIE 3 in past tense, lowercase cookie, formatting --- Doc/library/http.cookies.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst index d2cb6da9b99237..658b662168195c 100644 --- a/Doc/library/http.cookies.rst +++ b/Doc/library/http.cookies.rst @@ -18,16 +18,16 @@ cookie value. The module formerly strictly applied the parsing rules described in the :rfc:`2109` and :rfc:`2068` specifications. It has since been discovered that -MSIE 3.0x doesn't follow the character rules outlined in those specs and also -many current day browsers and servers have relaxed parsing rules when comes to -Cookie handling. As a result, the parsing rules used are a bit less strict. +MSIE 3.0x didn't follow the character rules outlined in those specs and also +many current day browsers and servers have relaxed parsing rules when it comes to +cookie handling. As a result, the parsing rules used are a bit less strict. The character set, :data:`string.ascii_letters`, :data:`string.digits` and ``!#$%&'*+-.^_`|~:`` denote the set of valid characters allowed by this module -in Cookie name (as :attr:`~Morsel.key`). +in a cookie name (as :attr:`~Morsel.key`). .. versionchanged:: 3.3 - Allowed ':' as a valid Cookie name character. + Allowed ':' as a valid cookie name character. .. note:: @@ -56,7 +56,7 @@ in Cookie name (as :attr:`~Morsel.key`). This class derives from :class:`BaseCookie` and overrides :meth:`~BaseCookie.value_decode` and :meth:`~BaseCookie.value_encode`. SimpleCookie supports strings as cookie values. - When setting the value, SimpleCookie calls the builtin :func:`str()` to convert + When setting the value, :class:`!SimpleCookie` calls the builtin :func:`str()` to convert the value to a string. Values received from HTTP are kept as strings. .. seealso:: From b88747a000372230e25e3b65f64274760499c2c0 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sun, 10 Dec 2023 03:43:59 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Alex Waygood --- Doc/library/http.cookies.rst | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst index 658b662168195c..e91972fe621a48 100644 --- a/Doc/library/http.cookies.rst +++ b/Doc/library/http.cookies.rst @@ -18,9 +18,10 @@ cookie value. The module formerly strictly applied the parsing rules described in the :rfc:`2109` and :rfc:`2068` specifications. It has since been discovered that -MSIE 3.0x didn't follow the character rules outlined in those specs and also -many current day browsers and servers have relaxed parsing rules when it comes to -cookie handling. As a result, the parsing rules used are a bit less strict. +MSIE 3.0x didn't follow the character rules outlined in those specs; many +current-day browsers and servers have also relaxed parsing rules when it comes +to cookie handling. As a result, this module now uses parsing rules that are a +bit less strict than they once were. The character set, :data:`string.ascii_letters`, :data:`string.digits` and ``!#$%&'*+-.^_`|~:`` denote the set of valid characters allowed by this module @@ -55,8 +56,9 @@ in a cookie name (as :attr:`~Morsel.key`). .. class:: SimpleCookie([input]) This class derives from :class:`BaseCookie` and overrides :meth:`~BaseCookie.value_decode` - and :meth:`~BaseCookie.value_encode`. SimpleCookie supports strings as cookie values. - When setting the value, :class:`!SimpleCookie` calls the builtin :func:`str()` to convert + and :meth:`~BaseCookie.value_encode`. :class:`!SimpleCookie` supports + strings as cookie values. When setting the value, :class:`!SimpleCookie` + calls the builtin :func:`str` to convert the value to a string. Values received from HTTP are kept as strings. .. seealso:: @@ -131,15 +133,15 @@ Morsel Objects Morsels are dictionary-like objects, whose set of keys is constant --- the valid :rfc:`2109` attributes, which are: - * .. attribute:: expires - * .. attribute:: path - * .. attribute:: comment - * .. attribute:: domain - * .. attribute:: max-age - * .. attribute:: secure - * .. attribute:: version - * .. attribute:: httponly - * .. attribute:: samesite + .. attribute:: expires + path + comment + domain + max-age + secure + version + httponly + samesite The attribute :attr:`httponly` specifies that the cookie is only transferred in HTTP requests, and is not accessible through JavaScript. This is intended