Both ``__get_item__`` and ``get`` call this function: it's never used elsewhere in Requests. :param name: a string containing name of cookie :param domain: (optional) string containing domain of cookie :param path: (optional) string containing path of cookie
(
self, name: str, domain: str | None = None, path: str | None = None
)
| 421 | raise KeyError(f"name={name!r}, domain={domain!r}, path={path!r}") |
| 422 | |
| 423 | def _find_no_duplicates( |
| 424 | self, name: str, domain: str | None = None, path: str | None = None |
| 425 | ) -> str: |
| 426 | """Both ``__get_item__`` and ``get`` call this function: it's never |
| 427 | used elsewhere in Requests. |
| 428 | |
| 429 | :param name: a string containing name of cookie |
| 430 | :param domain: (optional) string containing domain of cookie |
| 431 | :param path: (optional) string containing path of cookie |
| 432 | :raises KeyError: if cookie is not found |
| 433 | :raises CookieConflictError: if there are multiple cookies |
| 434 | that match name and optionally domain and path |
| 435 | :return: cookie.value |
| 436 | """ |
| 437 | toReturn = None |
| 438 | for cookie in iter(self): |
| 439 | if cookie.name == name: |
| 440 | if domain is None or cookie.domain == domain: |
| 441 | if path is None or cookie.path == path: |
| 442 | if toReturn is not None: |
| 443 | # if there are multiple cookies that meet passed in criteria |
| 444 | raise CookieConflictError( |
| 445 | f"There are multiple cookies with name, {name!r}" |
| 446 | ) |
| 447 | # we will eventually return this as long as no cookie conflict |
| 448 | toReturn = cookie.value |
| 449 | |
| 450 | if toReturn is not None: |
| 451 | return toReturn |
| 452 | raise KeyError(f"name={name!r}, domain={domain!r}, path={path!r}") |
| 453 | |
| 454 | def __getstate__(self) -> dict[str, Any]: |
| 455 | """Unlike a normal CookieJar, this class is pickleable.""" |
no test coverage detected