mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44:31 +03:00
Merge pull request #4694 from nulano/pyaccess-docs
Fix PyAccess docs using deferred_error
This commit is contained in:
commit
58c527d525
|
@ -23,23 +23,29 @@
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from cffi import FFI
|
try:
|
||||||
|
from cffi import FFI
|
||||||
|
|
||||||
|
defs = """
|
||||||
|
struct Pixel_RGBA {
|
||||||
|
unsigned char r,g,b,a;
|
||||||
|
};
|
||||||
|
struct Pixel_I16 {
|
||||||
|
unsigned char l,r;
|
||||||
|
};
|
||||||
|
"""
|
||||||
|
ffi = FFI()
|
||||||
|
ffi.cdef(defs)
|
||||||
|
except ImportError as ex:
|
||||||
|
# Allow error import for doc purposes, but error out when accessing
|
||||||
|
# anything in core.
|
||||||
|
from ._util import deferred_error
|
||||||
|
|
||||||
|
FFI = ffi = deferred_error(ex)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
defs = """
|
|
||||||
struct Pixel_RGBA {
|
|
||||||
unsigned char r,g,b,a;
|
|
||||||
};
|
|
||||||
struct Pixel_I16 {
|
|
||||||
unsigned char l,r;
|
|
||||||
};
|
|
||||||
"""
|
|
||||||
ffi = FFI()
|
|
||||||
ffi.cdef(defs)
|
|
||||||
|
|
||||||
|
|
||||||
class PyAccess:
|
class PyAccess:
|
||||||
def __init__(self, img, readonly=False):
|
def __init__(self, img, readonly=False):
|
||||||
vals = dict(img.im.unsafe_ptrs)
|
vals = dict(img.im.unsafe_ptrs)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user