recv_into(bytearray) complains about a "pinned buffer"

Martin v. Loewis martin at v.loewis.de
Mon Feb 1 03:30:56 CET 2010


> 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.

A pinned buffer is one that cannot move in memory, even if another
thread tries to behind your back. Typically, resizable containers
are not inherently pinned, and "a user" (i.e. the API function) must
explicitly pin it, which recv_into fails to do.

> Is this a bug in Python 2.6 or a deliberate choice regarding
> implementation concerns I don't know about?

It's actually a bug also that you pass an array; doing so *should*
give the very same error.

It may be that the bugs surrounding buffers will never get fully
resolved in the lifetime of Python 2.x, so I would probably just ignore
recv_into.

Regards,
Martin



More information about the Python-list mailing list