Skip to content
Myr

update 'merge_cookies' not to create new instance.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by daftshady · committed by daftshady · parent 1adba3c · Browse files · 2 files+12 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+12 added−9 removed

  • other:+12 added−9 removed

2 files+12 added−9 removed

modified:requests/cookies.py+11 added-7 removed
430 unmodified lines
431 """432 if not isinstance(cookiejar, cookielib.CookieJar):433 raise ValueError('You can only merge into CookieJar')434 435 merged_cookie = RequestsCookieJar()436 merged_cookie.update(cookiejar)437435 if isinstance(cookies, dict):439 merged_cookie = cookiejar_from_dict(440 cookies, cookiejar=merged_cookie, overwrite=False)436 cookiejar = cookiejar_from_dict(437 cookies, cookiejar=cookiejar, overwrite=False)438 elif isinstance(cookies, cookielib.CookieJar):439 try:440 if hasattr(cookiejar, 'update'):442 merged_cookie.update(cookies)441 cookiejar.update(cookies)442 else:443 raise CookieJarError444 except CookieJarError:445 for cookie_in_jar in cookies:446 cookiejar.set_cookie(cookie_in_jar)447444 return merged_cookie448 return cookiejar
modified:test_requests.py+1 added-2 removed
184 unmodified lines
185 r = s.get(httpbin('cookies'))186 # Make sure the cookie was sent187 assert r.json()['cookies']['foo'] == 'bar'188 # Make sure the session cj is still the custom one189 assert isinstance(s.cookies, cookielib.CookieJar)190 assert s.cookies['foo'] == 'bar'189 assert s.cookies is cj190 191 def test_param_cookiejar_works(self):192 cj = cookielib.CookieJar()193 cookiejar_from_dict({'foo' : 'bar'}, cj)
729 unmodified lines