A
Andrew Dalke
In Python 2.6 I can't socket.recv_into(a byte array instance). I get a
TypeError which complains about a "pinned buffer". I have only an
inkling of what that means. Since an array.array("b") works there, and
since it works in Python 3.1.1, and since I thought the point of a
bytearray was to make things like recv_into easier, I think this
exception is a bug in Python 2.6.
I want to double check before posting it to the tracker.
Here's my reproducibles:
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.Traceback (most recent call last):
I expected a bytearray to work there. In fact, I thought the point of
bytearray was to allow this to work.
By comparison, an array of bytes does work:
I don't even know what a "pinned buffer" means, and searching
python.org isn't helpful.
Using a bytearray in Python 3.1.1 *does* work:
Python 3.1.1 (r311:74480, Jan 31 2010, 23:07:16)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Is this a bug in Python 2.6 or a deliberate choice regarding
implementation concerns I don't know about?
If it's a bug, I'll add it to the tracker.
Andrew Dalke
(e-mail address removed)
TypeError which complains about a "pinned buffer". I have only an
inkling of what that means. Since an array.array("b") works there, and
since it works in Python 3.1.1, and since I thought the point of a
bytearray was to make things like recv_into easier, I think this
exception is a bug in Python 2.6.
I want to double check before posting it to the tracker.
Here's my reproducibles:
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.Traceback (most recent call last):
I expected a bytearray to work there. In fact, I thought the point of
bytearray was to allow this to work.
By comparison, an array of bytes does work:
'HTTP/1.1 302 F'import array
arr = array.array("b")
arr.extend(map(ord, "This is a test"))
len(arr) 14
sock.recv_into(arr) 14
arr array('b', [72, 84, 84, 80, 47, 49, 46, 49, 32, 51, 48, 50, 32, 70])
"".join(map(chr, arr))
I don't even know what a "pinned buffer" means, and searching
python.org isn't helpful.
Using a bytearray in Python 3.1.1 *does* work:
Python 3.1.1 (r311:74480, Jan 31 2010, 23:07:16)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Is this a bug in Python 2.6 or a deliberate choice regarding
implementation concerns I don't know about?
If it's a bug, I'll add it to the tracker.
Andrew Dalke
(e-mail address removed)