[Python-Dev] How to fix the buffer object's broken char buffersupport (original) (raw)

Brett Cannon brett at python.org
Wed Jun 7 19:01:24 CEST 2006


On 6/7/06, Kristján V. Jónsson <kristjan at ccpgames.com> wrote:

As a side note, It always seemed to me that the bfgetcharbuffer´s semantics were poorly defined. At least in the 2.3 documentation. Has that, and the need for it, changed recently?

I have tried to clean up the language a bit based on how I was interpreting the docs. Hopefully that isn't wrong since I am basing my patch on it. =)

But since I don't use buffers ever and Py3k is ditching buffers for the bytes type, I am personally not going to worry about changing their definition beyond clarifying the docs.

-Brett

Kristján

-----Original Message----- From: python-dev-bounces+kristjan=ccpgames.com at python.org [mailto:python-dev-bounces+kristjan=ccpgames.com at python.org] On Behalf Of Brett Cannon Sent: 6. júní 2006 22:30 To: Python Dev Subject: [Python-Dev] How to fix the buffer object's broken char buffersupport If you run import array; int(buffer(array.array('c'))) the interpreter will segfault. While investigating this I discovered that buffer objects, for their tpasbuffer->bfgetcharbuffer, return the result by calling the wrapped object bfgetreadbuffer or bfgetwritebuffer. This is wrong since it is essentially redirecting the expected call to the wrong tpasbuffer slot for the wrapped object. Plus it doesn't have PyTPFLAGSHAVEGETCHARBUFFER defined. I see two options here. One is to remove the bfgetcharbuffer slot from the buffer object. The other option is to fix it so that it only returns bfgetcharbuffer and doesn't redirect improperly (this also brings up the issue if PyTPFLAGSHAVEGETCHARBUFFER should then also be defined for buffer objects). Since I don't use buffer objects I don't know if it is better to fix this or just rip it out. -Brett


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/kristjan%40ccpgames.com


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/brett%40python.org



More information about the Python-Dev mailing list