Visitar URL original
incorrect "http.cookiejar bug" when catching exception · Issue #99453 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20221116202238/https://github.com/python/cpython/issues/99453
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect "http.cookiejar bug" when catching exception #99453

Open
nyuszika7h opened this issue Nov 13, 2022 · 0 comments
Open

incorrect "http.cookiejar bug" when catching exception #99453

nyuszika7h opened this issue Nov 13, 2022 · 0 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@nyuszika7h
Copy link

nyuszika7h commented Nov 13, 2022 •

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
@nyuszika7h nyuszika7h added the type-bug An unexpected behavior, bug, or error label Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant