[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-09-28 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Le mardi 28 septembre 2010 à 03:11 +, Lenard Lindstrom a écrit : Let's consider Pygame, and the SDL surface it wraps as a pygame.Surface. Pygame exposes a surface's data through the buffer protocol for manipulation by a NumPy array. Now

[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-09-28 Thread Lenard Lindstrom
Lenard Lindstrom le...@telus.net added the comment: I don't know why you're saying that. The purpose of PyBuffer_Release is precisely to solve these kinds of use cases (where you want timely release of a resource rather than rely on the garbage collector). Yes, I was unclear. This refers to

[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-09-28 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Yes, I was unclear. This refers to Python 3.2, not the 2.x series. PyObject_AsReadBuffer (defined at line 270 in abstract.c, code of routine attached) calls bf_getbuffer with the PyBUF_SIMPLE flag to retrieve a bytes buffer. It then calls

[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-09-28 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Le mardi 28 septembre 2010 22:24:56, vous avez écrit : I disagree. PyObject_As*Buffer functions are remnants of the old buffer API in Python 2.x. They are here only to ease porting of existing C code, but carefully written 3.x

[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-09-28 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Le mardi 28 septembre 2010 22:24:56, vous avez écrit : I disagree. PyObject_As*Buffer functions are remnants of the old buffer API in Python 2.x. They are here only to ease porting of existing C code, but carefully written 3.x code should

[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-09-28 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Ok, 3.x documentation is fixed to recommend the new buffer API funcs over the old compatibility funcs. On Victor's private suggestion, I'm now closing the issue. -- resolution: - wont fix status: open - closed

[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-09-28 Thread Lenard Lindstrom
Lenard Lindstrom le...@telus.net added the comment: That is perfectly fine with me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9602 ___ ___

[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-09-27 Thread Lenard Lindstrom
Lenard Lindstrom le...@telus.net added the comment: PEP 3118 Rationale ... 3) There is no way for a consumer to tell the buffer-API-exporting object it is finished with its view of the memory and therefore no way for the exporting object to be sure that it is safe to reallocate the pointer

[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-08-20 Thread Terry J. Reedy
Changes by Terry J. Reedy tjre...@udel.edu: -- versions: -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9602 ___ ___ Python-bugs-list

[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-08-17 Thread Marc-Andre Lemburg
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: STINNER Victor victor.stin...@haypocalc.com added the comment: Note that the buffer interface release API is meant to protect against such modifications, so I don't see why rejecting objects that do implement

[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-08-16 Thread Marc-Andre Lemburg
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: New submission from STINNER Victor victor.stin...@haypocalc.com: mmap, buffer, bytearray, string and unicode objects set the char buffer callback (bf_getcharbuffer). The bytearray object sets also the release

[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-08-16 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Note that the buffer interface release API is meant to protect against such modifications, so I don't see why rejecting objects that do implement this API should be rejected. As I explained, the release API is *not* used by

[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-08-14 Thread STINNER Victor
New submission from STINNER Victor victor.stin...@haypocalc.com: mmap, buffer, bytearray, string and unicode objects set the char buffer callback (bf_getcharbuffer). The bytearray object sets also the release buffer callback (bf_releasebuffer). In Python 2.7, PyObject_AsCharBuffer() accepts

[issue9602] PyObject_AsCharBuffer() should only accept read-only objects

2010-08-14 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I don't think we should change anything in 2.7 at this point. It risks breaking compatibility while we are at the end of the 2.x line, for little added benefit (the old buffer API has always been insecure with mutable buffers). As for 3.2,