diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py index 35ac2dc6ae280c..bea6eab031aa45 100644 --- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -598,15 +598,19 @@ 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. """ 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) 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