diff --git a/Tests/test_file_webp_metadata.py b/Tests/test_file_webp_metadata.py index 805125357..6cb61fdd4 100644 --- a/Tests/test_file_webp_metadata.py +++ b/Tests/test_file_webp_metadata.py @@ -5,8 +5,10 @@ from PIL import Image try: from PIL import _webp HAVE_WEBP = True + HAVE_WEBPANIM = True except ImportError: HAVE_WEBP = False + HAVE_WEBPANIM = False class TestFileWebpMetadata(PillowTestCase): @@ -110,7 +112,7 @@ class TestFileWebpMetadata(PillowTestCase): self.assertFalse(webp_image._getexif()) - @unittest.skipUnless(_webp.HAVE_WEBPANIM, 'WebP animation support not available') + @unittest.skipUnless(HAVE_WEBPANIM, 'WebP animation support not available') def test_write_animated_metadata(self): iccp_data = ''.encode('utf-8') exif_data = ''.encode('utf-8') diff --git a/_webp.c b/_webp.c index 4f43d6879..dcb2e29b5 100644 --- a/_webp.c +++ b/_webp.c @@ -19,14 +19,15 @@ #if WEBP_MUX_ABI_VERSION >= 0x0104 && WEBP_DEMUX_ABI_VERSION >= 0x0105 #define HAVE_WEBPANIM #endif -#endif -#ifdef HAVE_WEBPANIM +#endif /* -------------------------------------------------------------------- */ /* WebP Muxer Error Handling */ /* -------------------------------------------------------------------- */ +#ifdef HAVE_WEBPMUX + static const char* const kErrorMessages[-WEBP_MUX_NOT_ENOUGH_DATA + 1] = { "WEBP_MUX_NOT_FOUND", "WEBP_MUX_INVALID_ARGUMENT", "WEBP_MUX_BAD_DATA", "WEBP_MUX_MEMORY_ERROR", "WEBP_MUX_NOT_ENOUGH_DATA" @@ -67,10 +68,14 @@ PyObject* HandleMuxError(WebPMuxError err, char* chunk) { return NULL; } +#endif + /* -------------------------------------------------------------------- */ /* WebP Animation Support */ /* -------------------------------------------------------------------- */ +#ifdef HAVE_WEBPANIM + // Encoder type typedef struct { PyObject_HEAD