From 2a19acd9e39feafea5c6d450e820fbd37fc1249d Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Sat, 20 Jun 2020 15:40:36 -0400 Subject: [PATCH 1/5] Added SimpleCookie.value_encode/value_decode docs --- Lib/http/cookies.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py index 35ac2dc6ae280c..8cf917873c806a 100644 --- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -605,8 +605,16 @@ class SimpleCookie(BaseCookie): received from HTTP are kept as strings. """ def value_decode(self, val): + """ + Return an unquoted string, from the cookie header in a reversed fasion of value_encode. + """ + return _unquote(val), val def value_encode(self, val): + """ + Return an escaped quoted string, if needed, for the cookie header usage. + Will include non-compliant characters in the cookie value if exist. + """ strval = str(val) return strval, _quote(strval) From 73d527c1b6ee02bc63d122a58baffcaa6d2641b9 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 20 Jun 2020 19:47:31 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Documentation/2020-06-20-19-47-29.bpo-19670.wMt__Y.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2020-06-20-19-47-29.bpo-19670.wMt__Y.rst diff --git a/Misc/NEWS.d/next/Documentation/2020-06-20-19-47-29.bpo-19670.wMt__Y.rst b/Misc/NEWS.d/next/Documentation/2020-06-20-19-47-29.bpo-19670.wMt__Y.rst new file mode 100644 index 00000000000000..11c8692cc43ba8 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2020-06-20-19-47-29.bpo-19670.wMt__Y.rst @@ -0,0 +1 @@ +added documentation to `SimpleCookie.value_decode` and `SimpleCookie.value_encode` \ No newline at end of file From 9aef9f0cf1db2d961232cdd44e6b7409c3a54720 Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Sat, 20 Jun 2020 17:20:49 -0400 Subject: [PATCH 3/5] Added doc strings --- Lib/http/cookies.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py index 8cf917873c806a..6891382c7e50ed 100644 --- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -608,7 +608,6 @@ def value_decode(self, val): """ Return an unquoted string, from the cookie header in a reversed fasion of value_encode. """ - return _unquote(val), val def value_encode(self, val): From c458255db153b951c8682c6b8d703cd93d513193 Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Sun, 21 Jun 2020 08:47:28 -0400 Subject: [PATCH 4/5] Added doc strings --- Lib/http/cookies.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py index 6891382c7e50ed..10f92cb6826c75 100644 --- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -605,14 +605,12 @@ class SimpleCookie(BaseCookie): received from HTTP are kept as strings. """ def value_decode(self, val): - """ - Return an unquoted string, from the cookie header in a reversed fasion of value_encode. + """Return an unquoted string, from the cookie header in a reversed fasion of value_encode. """ return _unquote(val), val def value_encode(self, val): - """ - Return an escaped quoted string, if needed, for the cookie header usage. + """Return an escaped quoted string, if needed, for the cookie header usage. Will include non-compliant characters in the cookie value if exist. """ strval = str(val) From 74366e0414b6881b2416605dde2663b43d72ff20 Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Sat, 27 Jun 2020 14:18:18 -0400 Subject: [PATCH 5/5] Fixed typo + reverted the url parse last section --- Lib/http/cookies.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py index 10f92cb6826c75..bea6eab031aa45 100644 --- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -598,8 +598,7 @@ def __parse_string(self, str, patt=_CookiePattern): class SimpleCookie(BaseCookie): - """ - SimpleCookie supports strings as cookie values. When setting + """SimpleCookie supports strings as cookie values. When setting the value using the dictionary assignment notation, SimpleCookie calls the builtin str() to convert the value to a string. Values received from HTTP are kept as strings.