mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-42066: CookieJar cookies should not be sorted (GH-22745)
This commit is contained in:
parent
031f1e6040
commit
615b24c80b
3 changed files with 9 additions and 12 deletions
|
@ -1224,14 +1224,9 @@ class DefaultCookiePolicy(CookiePolicy):
|
||||||
_debug(" %s does not path-match %s", req_path, path)
|
_debug(" %s does not path-match %s", req_path, path)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def vals_sorted_by_key(adict):
|
|
||||||
keys = sorted(adict.keys())
|
|
||||||
return map(adict.get, keys)
|
|
||||||
|
|
||||||
def deepvalues(mapping):
|
def deepvalues(mapping):
|
||||||
"""Iterates over nested mapping, depth-first, in sorted order by key."""
|
"""Iterates over nested mapping, depth-first"""
|
||||||
values = vals_sorted_by_key(mapping)
|
for obj in list(mapping.values()):
|
||||||
for obj in values:
|
|
||||||
mapping = False
|
mapping = False
|
||||||
try:
|
try:
|
||||||
obj.items
|
obj.items
|
||||||
|
|
|
@ -1293,11 +1293,11 @@ class CookieTests(unittest.TestCase):
|
||||||
r'port="90,100, 80,8080"; '
|
r'port="90,100, 80,8080"; '
|
||||||
r'max-age=100; Comment = "Just kidding! (\"|\\\\) "')
|
r'max-age=100; Comment = "Just kidding! (\"|\\\\) "')
|
||||||
|
|
||||||
versions = [1, 1, 1, 0, 1]
|
versions = [1, 0, 1, 1, 1]
|
||||||
names = ["bang", "foo", "foo", "spam", "foo"]
|
names = ["foo", "spam", "foo", "foo", "bang"]
|
||||||
domains = [".sol.no", "blah.spam.org", "www.acme.com",
|
domains = ["blah.spam.org", "www.acme.com", "www.acme.com",
|
||||||
"www.acme.com", "www.acme.com"]
|
"www.acme.com", ".sol.no"]
|
||||||
paths = ["/", "/", "/", "/blah", "/blah/"]
|
paths = ["/", "/blah", "/blah/", "/", "/"]
|
||||||
|
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
i = 0
|
i = 0
|
||||||
|
|
|
@ -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.
|
Loading…
Add table
Add a link
Reference in a new issue