I'm trying to create an object (as a C extension) to support the buffer
interface and was getting "TypeError: buffer is read-only" errors. So I
had a look at the array object and it has the same problem:
$ python
array('c', 'abc')
'a'
array('c', 'dbc')
'd'
TypeError: buffer is read-only
The array is a mutable (writable) object, and the array implements the
buffer interface and provides a 'getwritebuf' method.
(Python-2.4.4/Modules/arraymodule.c has an array_buffer_ge twritebuf())
so why does it give "TypeError: buffer is read-only"?
Steve
interface and was getting "TypeError: buffer is read-only" errors. So I
had a look at the array object and it has the same problem:
$ python
>>import array
>>a=array.array ('c', ['a', 'b', 'c'])
>>a
>>a=array.array ('c', ['a', 'b', 'c'])
>>a
>>a[0]
>>a[0]='d'
>>a
>>a
>>buf=buffer( a)
>>buf[0]
>>buf[0]
>>buf[0]='e'
The array is a mutable (writable) object, and the array implements the
buffer interface and provides a 'getwritebuf' method.
(Python-2.4.4/Modules/arraymodule.c has an array_buffer_ge twritebuf())
so why does it give "TypeError: buffer is read-only"?
Steve