You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: USAGE.rst
+1-23Lines changed: 1 addition & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -372,15 +372,7 @@ In some cases this includes writing to the data.
372
372
buf = thumb.copy()
373
373
thumb_im =PIL.Image.open(io.BytesIO(buf.data()))
374
374
375
-
In python-exiv2 before v0.15.0 the memory block is converted to an object with a buffer interface.
376
-
A Python memoryview_ can be used to access the data without copying.
377
-
(Converting to bytes_ would make a copy of the data, which we don't usually want.)
378
-
379
-
Warning: segmentation faults
380
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
381
-
382
-
Note that the memory block must not be deleted or resized while the memoryview exists.
383
-
Doing so will invalidate the memoryview and may cause a segmentation fault:
375
+
Since version 0.18.0 python-exiv2 releases the memoryview (when the memory block is resized or deleted) to prevent problems such as segmentation faults:
384
376
385
377
.. code:: python
386
378
@@ -390,24 +382,10 @@ Doing so will invalidate the memoryview and may cause a segmentation fault:
390
382
b'fred'
391
383
>>>del buf
392
384
>>>print(bytes(data))
393
-
b'en_G'
394
-
395
-
Since version 0.18.0 python-exiv2 releases the memoryview (when the memory block is resized) to prevent problems:
396
-
397
-
.. code:: python
398
-
399
-
>>> buf = exiv2.DataBuf(b'fred')
400
-
>>> data = buf.data()
401
-
>>>print(bytes(data))
402
-
b'fred'
403
-
>>> buf.alloc(128)
404
-
>>>print(bytes(data))
405
385
Traceback (most recent call last):
406
386
File "<stdin>", line 1, in<module>
407
387
ValueError: operation forbidden on released memoryviewobject
408
388
409
-
Unfortunately I haven't been able to make this work for memory block deletion.
0 commit comments