- Fix _webp reference when _webp is not available

- HandleMuxError function needs to be tied to WEBP_HAVEMUX, not WEBP_HAVEANIM
This commit is contained in:
Jason Douglas 2017-09-27 22:13:13 -07:00
parent 405d1a64d8
commit acc4334291
2 changed files with 10 additions and 3 deletions

View File

@ -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 = '<iccp_data>'.encode('utf-8')
exif_data = '<exif_data>'.encode('utf-8')

View File

@ -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