[New-bugs-announce] [issue4509] possible memoryview bug

gumpy report at bugs.python.org
Wed Dec 3 23:06:38 CET 2008


New submission from gumpy <gumpy2k7 at gmail.com>:

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'

----------
components: Interpreter Core
messages: 76849
nosy: gumpy
severity: normal
status: open
title: possible memoryview bug
type: behavior
versions: Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4509>
_______________________________________


More information about the New-bugs-announce mailing list