mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Include limit in error message
This commit is contained in:
parent
f368ccc06e
commit
d49ea37811
|
@ -163,7 +163,9 @@ class TestFileWebp:
|
|||
im = Image.new("L", (16384, 16384))
|
||||
with pytest.raises(ValueError) as e:
|
||||
im.save(temp_file)
|
||||
assert str(e.value) == "encoding error 5: Image size exceeds WebP limit"
|
||||
assert (
|
||||
str(e.value) == "encoding error 5: Image size exceeds WebP limit of 16383"
|
||||
)
|
||||
|
||||
def test_WebPEncode_with_invalid_args(self) -> None:
|
||||
"""
|
||||
|
|
|
@ -673,9 +673,11 @@ WebPEncode_wrapper(PyObject *self, PyObject *args) {
|
|||
WebPPictureFree(&pic);
|
||||
if (!ok) {
|
||||
int error_code = (&pic)->error_code;
|
||||
const char *message = "";
|
||||
char message[50] = "";
|
||||
if (error_code == VP8_ENC_ERROR_BAD_DIMENSION) {
|
||||
message = ": Image size exceeds WebP limit";
|
||||
sprintf(
|
||||
message, ": Image size exceeds WebP limit of %d", WEBP_MAX_DIMENSION
|
||||
);
|
||||
}
|
||||
PyErr_Format(PyExc_ValueError, "encoding error %d%s", error_code, message);
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue
Block a user