Skip to content

List of documented exceptions doesn't match reality / unused URLRequired exception #6877

@The-Compiler

Description

@The-Compiler

The documentation lists a relatively small list of exceptions, among them:

exception requests.URLRequired(*args, **kwargs)
A valid URL is required to make a request.

which would imply that passing an invalid URL raises URLRequired. However, that exception is actually dead code and not raised anywhere ever since ab27027 in 2012. Instead, with requests 2.32.3, invalid URLs raise something like MissingSchema, InvalidSchema or InvalidURL, none of which are documented.

Looking at exceptions.py, there seem to be various other undocumented exceptions in there:

  • class InvalidJSONError(RequestException): (only JSONDecodeError which inherits from it)
  • class ProxyError(ConnectionError):
  • class SSLError(ConnectionError):
  • class ConnectTimeout(ConnectionError, Timeout): (Timeout is documented)
  • class ReadTimeout(Timeout): (Timeout is documented)
  • class MissingSchema(RequestException, ValueError):
  • class InvalidSchema(RequestException, ValueError):
  • class InvalidURL(RequestException, ValueError):
  • class InvalidHeader(RequestException, ValueError):
  • class InvalidProxyURL(InvalidURL):
  • class ChunkedEncodingError(RequestException):
  • class ContentDecodingError(RequestException, BaseHTTPError):
  • class StreamConsumedError(RequestException, TypeError):
  • class RetryError(RequestException):
  • class UnrewindableBodyError(RequestException):

(Some of those might be internal, or considered not worth documenting since they can be caught by except ValueError:. However, even e.g. Errors and Exceptions or the reference docs don't seem to point out that either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions