mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-28 02:04:36 +03:00
Pull readonly in from the C level
This commit is contained in:
parent
55f5351e3d
commit
ad492ee4d8
|
@ -147,3 +147,11 @@ def test_release_array():
|
|||
array, schema = img.__arrow_c_array__()
|
||||
del(array)
|
||||
del(schema)
|
||||
|
||||
|
||||
def test_readonly():
|
||||
img = hopper('L')
|
||||
reloaded = Image.fromarrow(img, img.mode, img.size)
|
||||
assert reloaded.readonly == 1
|
||||
reloaded._readonly = 0
|
||||
assert reloaded.readonly == 1
|
||||
|
|
|
@ -584,6 +584,14 @@ class Image:
|
|||
def mode(self) -> str:
|
||||
return self._mode
|
||||
|
||||
@property
|
||||
def readonly(self) -> int:
|
||||
return (self._im and self._im.readonly) or self._readonly
|
||||
|
||||
@readonly.setter
|
||||
def readonly(self, readonly: int) -> None:
|
||||
self._readonly = readonly
|
||||
|
||||
def _new(self, im: core.ImagingCore) -> Image:
|
||||
new = Image()
|
||||
new.im = im
|
||||
|
|
|
@ -3821,6 +3821,11 @@ _getattr_unsafe_ptrs(ImagingObject *self, void *closure) {
|
|||
);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_getattr_readonly(ImagingObject *self, void *closure) {
|
||||
return PyLong_FromLong(self->image->read_only);
|
||||
}
|
||||
|
||||
static struct PyGetSetDef getsetters[] = {
|
||||
{"mode", (getter)_getattr_mode},
|
||||
{"size", (getter)_getattr_size},
|
||||
|
@ -3828,6 +3833,7 @@ static struct PyGetSetDef getsetters[] = {
|
|||
{"id", (getter)_getattr_id},
|
||||
{"ptr", (getter)_getattr_ptr},
|
||||
{"unsafe_ptrs", (getter)_getattr_unsafe_ptrs},
|
||||
{"readonly", (getter)_getattr_readonly},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user