-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description
Bug report
catching certain exceptions from the http.cookiejar
module incorrectly triggers an "unhandled exception" warning:
#!/usr/bin/env python3
import logging
from http.cookiejar import LoadError, MozillaCookieJar
from tempfile import NamedTemporaryFile
logging.basicConfig()
log = logging.getLogger()
with NamedTemporaryFile(mode="w") as tmp:
tmp.write("# Netscape HTTP Cookie File\n%3D\n")
tmp.seek(0)
jar = MozillaCookieJar(tmp.name)
try:
jar.load()
except LoadError:
log.warning("Failed to load cookies")
alexia@cadoth ~ > ./http_cookiejar_bug.py
/home/alexia/.local/share/pyenv/versions/3.11.0/lib/python3.11/http/cookiejar.py:2080: UserWarning: http.cookiejar bug!
Traceback (most recent call last):
File "/home/alexia/.local/share/pyenv/versions/3.11.0/lib/python3.11/http/cookiejar.py", line 2041, in _really_load
domain, domain_specified, path, secure, expires, name, value = \
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 7, got 1)
_warn_unhandled_exception()
WARNING:root:Failed to load cookies
Your environment
- CPython versions tested on: 3.9.2, 3.10.8, 3.11.0
- Operating system and architecture: Debian 11 amd64
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
No status