diff options
author | Iman Kermani <55282537+IKermani@users.noreply.github.com> | 2022-04-21 01:45:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-21 01:45:24 (GMT) |
commit | 615b24c80b0bbbc7b70aa1e9c28f9c4463c8c1ed (patch) | |
tree | 681ceb78d2709f4b39aa2082b49270aec7a1d0b1 | |
parent | 031f1e6040d1bb0454bd6da417fd9e38aad4fc89 (diff) | |
download | cpython-615b24c80b0bbbc7b70aa1e9c28f9c4463c8c1ed.zip cpython-615b24c80b0bbbc7b70aa1e9c28f9c4463c8c1ed.tar.gz cpython-615b24c80b0bbbc7b70aa1e9c28f9c4463c8c1ed.tar.bz2 |
bpo-42066: CookieJar cookies should not be sorted (GH-22745)
-rw-r--r-- | Lib/http/cookiejar.py | 9 | ||||
-rw-r--r-- | Lib/test/test_http_cookiejar.py | 10 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2020-10-19-08-50-41.bpo-42066.DsB-R6.rst | 2 |
3 files changed, 9 insertions, 12 deletions
diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py index 136a1f16..f19a366 100644 --- a/Lib/http/cookiejar.py +++ b/Lib/http/cookiejar.py @@ -1224,14 +1224,9 @@ class DefaultCookiePolicy(CookiePolicy): _debug(" %s does not path-match %s", req_path, path) return False -def vals_sorted_by_key(adict): - keys = sorted(adict.keys()) - return map(adict.get, keys) - def deepvalues(mapping): - """Iterates over nested mapping, depth-first, in sorted order by key.""" - values = vals_sorted_by_key(mapping) - for obj in values: + """Iterates over nested mapping, depth-first""" + for obj in list(mapping.values()): mapping = False try: obj.items diff --git a/Lib/test/test_http_cookiejar.py b/Lib/test/test_http_cookiejar.py index 126ce4f..ad2b121 100644 --- a/Lib/test/test_http_cookiejar.py +++ b/Lib/test/test_http_cookiejar.py @@ -1293,11 +1293,11 @@ class CookieTests(unittest.TestCase): r'port="90,100, 80,8080"; ' r'max-age=100; Comment = "Just kidding! (\"|\\\\) "') - versions = [1, 1, 1, 0, 1] - names = ["bang", "foo", "foo", "spam", "foo"] - domains = [".sol.no", "blah.spam.org", "www.acme.com", - "www.acme.com", "www.acme.com"] - paths = ["/", "/", "/", "/blah", "/blah/"] + versions = [1, 0, 1, 1, 1] + names = ["foo", "spam", "foo", "foo", "bang"] + domains = ["blah.spam.org", "www.acme.com", "www.acme.com", + "www.acme.com", ".sol.no"] + paths = ["/", "/blah", "/blah/", "/", "/"] for i in range(4): i = 0 diff --git a/Misc/NEWS.d/next/Library/2020-10-19-08-50-41.bpo-42066.DsB-R6.rst b/Misc/NEWS.d/next/Library/2020-10-19-08-50-41.bpo-42066.DsB-R6.rst new file mode 100644 index 0000000..f3de854 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-10-19-08-50-41.bpo-42066.DsB-R6.rst @@ -0,0 +1,2 @@ +Fix cookies getting sorted in :func:`CookieJar.__iter__` which is an extra behavior and not mentioned in RFC 2965 or Netscape cookie protocol.
+Now the cookies in ``CookieJar`` follows the order of the ``Set-Cookie`` header. Patch by Iman Kermani.
|