diff --git a/AUTHORS.rst b/AUTHORS.rst index b0594a6b..6a7f889b 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -161,3 +161,4 @@ Patches and Suggestions - Colin Dickson (`@colindickson `_) - Smiley Barry (`@smiley `_) - Shagun Sodhani (`@shagunsodhani `_) +- Robin Linderborg (`@vienno `_) diff --git a/requests/cookies.py b/requests/cookies.py index 88b478c7..d097d7db 100644 --- a/requests/cookies.py +++ b/requests/cookies.py @@ -143,10 +143,13 @@ def remove_cookie_by_name(cookiejar, name, domain=None, path=None): """ clearables = [] for cookie in cookiejar: - if cookie.name == name: - if domain is None or domain == cookie.domain: - if path is None or path == cookie.path: - clearables.append((cookie.domain, cookie.path, cookie.name)) + if cookie.name != name: + continue + if domain is not None and domain != cookie.domain: + continue + if path is not None and path != cookie.path: + continue + clearables.append((cookie.domain, cookie.path, cookie.name)) for domain, path, name in clearables: cookiejar.clear(domain, path, name)