https://github.com/python/cpython/commit/87f8c0d8a3214eafad87d2648102644a501452fa commit: 87f8c0d8a3214eafad87d2648102644a501452fa branch: main author: Senthil Kumaran <[email protected]> committer: orsenthil <[email protected]> date: 2026-10-28T08:55:44-07:00 summary:
gh-57945: Document exceptions not wrapped by urlopen() (#160830) Exceptions raised while reading or parsing the HTTP response, such as http.client.HTTPException subclasses and OSError subclasses like TimeoutError, propagate from urlopen() without being wrapped in URLError. Document this, and that ValueError is raised for an invalid URL. Co-authored-by: Claude Opus 5.5 <[email protected]> files: M Doc/library/urllib.request.rst diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index e1581e213c5ca8..9a75f4986e1a3a 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -68,6 +68,16 @@ The :mod:`!urllib.request` module defines the following functions: Raises :exc:`~urllib.error.URLError` on protocol errors. + Exceptions raised while reading or parsing an HTTP response are not + wrapped in :exc:`~urllib.error.URLError` and propagate unchanged. + These include subclasses of :exc:`http.client.HTTPException`, such as + :exc:`~http.client.BadStatusLine` for a malformed status line, and + subclasses of :exc:`OSError`, such as :exc:`TimeoutError` if the server + does not respond within *timeout* seconds, or + :exc:`~http.client.RemoteDisconnected` if the server closes the + connection without sending a response. :exc:`ValueError` is raised if + *url* is not a valid URL. + Note that ``None`` may be returned if no handler handles the request (though the default installed global :class:`OpenerDirector` uses :class:`UnknownHandler` to ensure this never happens). _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
