We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 73f5684 + 7119ef5 commit 58c527dCopy full SHA for 58c527d
1 file changed
src/PIL/PyAccess.py
@@ -23,23 +23,29 @@
23
import logging
24
import sys
25
26
-from cffi import FFI
+try:
27
+ from cffi import FFI
28
+
29
+ defs = """
30
+ struct Pixel_RGBA {
31
+ unsigned char r,g,b,a;
32
+ };
33
+ struct Pixel_I16 {
34
+ unsigned char l,r;
35
36
+ """
37
+ ffi = FFI()
38
+ ffi.cdef(defs)
39
+except ImportError as ex:
40
+ # Allow error import for doc purposes, but error out when accessing
41
+ # anything in core.
42
+ from ._util import deferred_error
43
44
+ FFI = ffi = deferred_error(ex)
45
46
logger = logging.getLogger(__name__)
47
48
-defs = """
-struct Pixel_RGBA {
- unsigned char r,g,b,a;
-};
-struct Pixel_I16 {
- unsigned char l,r;
-"""
-ffi = FFI()
-ffi.cdef(defs)
-
49
class PyAccess:
50
def __init__(self, img, readonly=False):
51
vals = dict(img.im.unsafe_ptrs)
0 commit comments