Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Fixes:
- Add ``cython.final`` to leaf classes, ensuring that they are not subclassed.
- Warn that ``CodecContext.decode()`` is not memory safe in some cases.
- Fix ``enumerate_input_devices`` and ``enumerate_output_devices`` raising ``AttributeError`` (:issue:`2264`).
- Map HTTP 429 to ``HTTPTooManyRequestsError`` instead of ``UndefinedError`` (:issue:`2267`).

v17.0.1
-------
Expand Down
1 change: 1 addition & 0 deletions av/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class HTTPClientError(FFmpegError):
("HTTP_UNAUTHORIZED", -lib.AVERROR_HTTP_UNAUTHORIZED, "HTTPUnauthorizedError", HTTPClientError),
("HTTP_FORBIDDEN", -lib.AVERROR_HTTP_FORBIDDEN, "HTTPForbiddenError", HTTPClientError),
("HTTP_NOT_FOUND", -lib.AVERROR_HTTP_NOT_FOUND, "HTTPNotFoundError", HTTPClientError),
("HTTP_TOO_MANY_REQUESTS", -lib.AVERROR_HTTP_TOO_MANY_REQUESTS, "HTTPTooManyRequestsError", HTTPClientError),
("HTTP_OTHER_4XX", -lib.AVERROR_HTTP_OTHER_4XX, "HTTPOtherClientError", HTTPClientError),
("HTTP_SERVER_ERROR", -lib.AVERROR_HTTP_SERVER_ERROR, "HTTPServerError", HTTPError),
("PYAV_CALLBACK", c_PYAV_STASHED_ERROR, "PyAVCallbackError", RuntimeError),
Expand Down
1 change: 1 addition & 0 deletions av/error.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class HTTPBadRequestError(HTTPClientError): ...
class HTTPUnauthorizedError(HTTPClientError): ...
class HTTPForbiddenError(HTTPClientError): ...
class HTTPNotFoundError(HTTPClientError): ...
class HTTPTooManyRequestsError(HTTPClientError): ...
class HTTPOtherClientError(HTTPClientError): ...
class HTTPServerError(HTTPError): ...
class PyAVCallbackError(FFmpegError, builtins.RuntimeError): ...
Expand Down
1 change: 1 addition & 0 deletions include/avutil.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ cdef extern from "libavutil/error.h" nogil:
cdef int AVERROR_HTTP_UNAUTHORIZED
cdef int AVERROR_HTTP_FORBIDDEN
cdef int AVERROR_HTTP_NOT_FOUND
cdef int AVERROR_HTTP_TOO_MANY_REQUESTS
cdef int AVERROR_HTTP_OTHER_4XX
cdef int AVERROR_HTTP_SERVER_ERROR
cdef int AV_ERROR_MAX_STRING_SIZE
Expand Down
13 changes: 13 additions & 0 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,16 @@ def test_buffertoosmall() -> None:
assert e.errno == BUFFER_TOO_SMALL
else:
assert False, "No exception raised!"


def test_http_too_many_requests() -> None:
"""HTTP 429 maps to HTTPTooManyRequestsError, not UndefinedError."""

HTTP_TOO_MANY_REQUESTS = av.error.tag_to_code(b"\xf8429")
try:
av.error.err_check(-HTTP_TOO_MANY_REQUESTS)
except av.error.HTTPTooManyRequestsError as e:
assert e.errno == HTTP_TOO_MANY_REQUESTS
assert isinstance(e, av.error.HTTPClientError)
else:
assert False, "No exception raised!"
Loading