[Python-Dev] Re: [Python-checkins] python/dist/src/Objects bufferobject.c, 2.22, 2.23 (original) (raw)

Neil Schemenauer nas-python at python.ca
Wed Mar 10 22:01:34 EST 2004


On Wed, Mar 10, 2004 at 06:42:47PM -0800, nascheme at users.sourceforge.net wrote:

Modified Files: bufferobject.c Log Message: Make buffer objects based on immutable objects (like array) safe.

Perfect is the enemy of better.

I would appreciate it if people could review this change. The potential for range errors seems high. I tried hard to make the change more easily reviewable (at some cost to the resulting code readability).

The mean idea of the change is that instead of using b_ptr and b_size directly, get_buf() is called as necessary to retrieve them. If the buffer is based on memory then b_ptr and b_size are set normally and get_buf() just returns them. If the buffer is based on an object then get_buf() calls the tp_as_buffer method to retrieve them.

I believe this fixes the nastier problems of the buffer object. The only remaining problem that I know of is that buffer_hash may not raise a TypeError when it really should.

Neil



More information about the Python-Dev mailing list