homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrah
Recipients ncoghlan, pitrou, skrah
Date 2011年08月22日.11:13:30
SpamBayes Score 3.6600667e-09
Marked as misclassified No
Message-id <1314011611.8.0.941911218938.issue12817@psf.upfronthosting.co.za>
In-reply-to
Content
Hello,
in my private repo I've changed memoryview's getbufferproc to be PEP-3118
compliant. test_multiprocessing does the equivalent of the following sequence,
which is not allowed by PEP-3118:
>>> import array, io
>>> a = array.array('i', [1,2,3,4,5])
>>> m = memoryview(a)
>>> m.format
'i'
>>> buf = io.BytesIO(bytearray(5))
>>> buf.readinto(m)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
TypeError: expected an object with a writable buffer interface
>>>
The error occurs in Objects/abstract.c:315:
 ((*pb->bf_getbuffer)(obj, &view, PyBUF_WRITABLE) != 0))
Here, PyObject_AsWriteBuffer() requests a simple writable buffer of unsigned
bytes *without format information* from the memoryview. The memoryview's
getbufferproc is required to return an error:
"If format is not explicitly requested then the format must be returned
 as NULL (which means "B", or unsigned bytes)."
But the underlying buffer has format 'i' and not 'B', hence the error.
Antoine, is it correct that io.BytesIO should only be used with bytearray
buffers?
If so, this is a bug in the tests (patch attached).
History
Date User Action Args
2011年08月22日 11:13:31skrahsetrecipients: + skrah, ncoghlan, pitrou
2011年08月22日 11:13:31skrahsetmessageid: <1314011611.8.0.941911218938.issue12817@psf.upfronthosting.co.za>
2011年08月22日 11:13:31skrahlinkissue12817 messages
2011年08月22日 11:13:30skrahcreate

AltStyle によって変換されたページ (->オリジナル) /