Re: recv_into(bytearray) complains about a "pinned buffer"

2010-02-02 Thread Martin v. Loewis
> Clearly it was added to work with an array, and it's > being used with an array. Why shouldn't people use it > with Python 2.x? Because it's not thread-safe; it may crash the interpreter if used incorrectly. Of course, if you don't share the array across threads, it can be safe to use. Regards

Re: recv_into(bytearray) complains about a "pinned buffer"

2010-02-02 Thread Antoine Pitrou
Le Tue, 02 Feb 2010 00:12:34 +0100, Martin v. Loewis a écrit : >> recv_into() should simply be fixed to use the new buffer API, as it >> does in 3.x. > > I don't think that's the full solution. The array module should also > implement the new buffer API, so that it would also fail with the old > r

Re: recv_into(bytearray) complains about a "pinned buffer"

2010-02-01 Thread Andrew Dalke
On Feb 2, 12:12 am, Martin v. Loewis wrote: > My recommendation would be to not use recv_into in 2.x, but only in 3.x. > I don't think that's the full solution. The array module should also > implement the new buffer API, so that it would also fail with the old > recv_into. Okay. But recv_into wa

Re: recv_into(bytearray) complains about a "pinned buffer"

2010-02-01 Thread Martin v. Loewis
Antoine Pitrou wrote: > Le Mon, 01 Feb 2010 03:30:56 +0100, Martin v. Loewis a écrit : >>> 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.

Re: recv_into(bytearray) complains about a "pinned buffer"

2010-02-01 Thread Antoine Pitrou
Le Mon, 01 Feb 2010 03:30:56 +0100, Martin v. Loewis a écrit : > >> 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. Well, if you can give

Re: recv_into(bytearray) complains about a "pinned buffer"

2010-01-31 Thread Martin v. Loewis
> 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 conta

Re: recv_into(bytearray) complains about a "pinned buffer"

2010-01-31 Thread Andrew Dalke
On Feb 1, 1:04 am, Antoine Pitrou wrote: > The problem is that socket.recv_into() in 2.6 doesn't recognize the new > buffer API which is needed to accept bytearray objects. > (it does in 3.1, because the old buffer API doesn't exist anymore there) That's about what I thought it was, but I don't k

Re: recv_into(bytearray) complains about a "pinned buffer"

2010-01-31 Thread Antoine Pitrou
Hello Andrew, > 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: > [...] Agreed, the error message is cryptic. The problem is that socket.recv_into() in 2.6 doesn't recognize the new buffer API which is

recv_into(bytearray) complains about a "pinned buffer"

2010-01-31 Thread 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 th