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 gumpy
Recipients gumpy
Date 2008-12-03.22:06:37
SpamBayes Score 3.166703e-08
Marked as misclassified No
Message-id <1228341998.62.0.651194722962.issue4509@psf.upfronthosting.co.za>
In-reply-to
Content
I'm unsure of the expected behavior in this case but it seems odd. The
bytearray in the following example can be resized to a length of 5-10
bytes without throwing an exception.


Python 3.0rc3 (r30rc3:67312, Dec  3 2008, 10:38:14) 

[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2

>>> b = bytearray(b'x' * 10)

>>> v = memoryview(b)

>>> b[:] = b'y' * 11

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

BufferError: Existing exports of data: object cannot be re-sized

>>> b[:] = b'y' * 5

>>> b

bytearray(b'yyyyy')

>>> v.tobytes()

b'yyyyy\x00xxxx'

>>> v2 = memoryview(b)

>>> v2.tobytes()

b'yyyyy'
History
Date User Action Args
2008-12-03 22:06:38gumpysetrecipients: + gumpy
2008-12-03 22:06:38gumpysetmessageid: <1228341998.62.0.651194722962.issue4509@psf.upfronthosting.co.za>
2008-12-03 22:06:38gumpylinkissue4509 messages
2008-12-03 22:06:37gumpycreate