Re: [Python-3000] Odd output from test -- buffering bug?

2007-10-29 Thread Guido van Rossum
Thinking about this some more, the io module isn't thread-safe. It probably should be (the old file objects were more-or-less thread-safe, although I believe there might've been corner cases if one thread were to close a file). --Guido 2007/10/27, Bill Janssen <[EMAIL PROTECTED]>: > No, not unles

Re: [Python-3000] bug in i/o module buffering?

2007-10-29 Thread Guido van Rossum
__index__() converts an "int-like" object to an int. This is needed to make sure that e.g. numpy integral scalars can be used for indexing. For a regular int it doesn't matter, so here it's a red herring. I'm asking about b because the error message "TypeError: 'slice' object does not support item

Re: [Python-3000] __bool__ in 2.6?

2007-10-29 Thread Guido van Rossum
2007/10/28, Brett Cannon <[EMAIL PROTECTED]>: > On 10/28/07, James Thiele <[EMAIL PROTECTED]> wrote: > > PEP 361 lists __bool__ support as being possible for 2.6 backporting. > > As of today the trunk build uses __nonzero__ like 2.5 but 3.0 alpha > > uses __bool__. Has a decision been made on wheth

Re: [Python-3000] plat-mac seriously broken?

2007-10-29 Thread Guido van Rossum
2007/10/27, Bill Janssen <[EMAIL PROTECTED]>: > > ISTR much of the plat-mac stuff was generated by Tools/bgen. If so, that > > would be the place to fix things. > > Sure looks like generated code. Be nice if that generator was run > during the build process, on OS X. That way you'd be sure to ge

Re: [Python-3000] __bool__ in 2.6?

2007-10-29 Thread Guido van Rossum
2007/10/29, Fred Drake <[EMAIL PROTECTED]>: > On Oct 29, 2007, at 2:40 PM, James Thiele wrote: > > So just to clarify: > > 2.6 __nonzero__ first, then __bool__ (if patch submitted) > > 3.x __bool__ first, then __nonzero__ > > I'd expect switching the order for this to be a bug magnet. I'd much > r

Re: [Python-3000] socket GC worries

2007-10-29 Thread Guido van Rossum
2007/10/28, Bill Janssen <[EMAIL PROTECTED]>: > > Bill Janssen wrote: > > > that whole mess of code is a good argument for *not* exposing the > > > fileno in Python > > > > Seems to me that a socket should already *be* a file, > > so it shouldn't need a makefile() method and you > > shouldn't have

Re: [Python-3000] __bool__ in 2.6?

2007-10-29 Thread Fred Drake
On Oct 29, 2007, at 2:40 PM, James Thiele wrote: > So just to clarify: > 2.6 __nonzero__ first, then __bool__ (if patch submitted) > 3.x __bool__ first, then __nonzero__ I'd expect switching the order for this to be a bug magnet. I'd much rather see: 2.5 __nonzero__ only 2.6 __bool__ first, th

Re: [Python-3000] __bool__ in 2.6?

2007-10-29 Thread James Thiele
So just to clarify: 2.5 __nonzero__ only 2.6 __nonzero__ first, then __bool__ (if patch submitted) 3.x __bool__ first, then __nonzero__ Is this correct? On 10/29/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > 2007/10/28, Brett Cannon <[EMAIL PROTECTED]>: > > On 10/28/07, James Thiele <[EMAIL P

Re: [Python-3000] Please re-add __cmp__ to python 3000

2007-10-29 Thread David A. Wheeler
I think several postings have explained better than I have on why __cmp__ is still very valuable. (See below.) Guido van Rossum posted earlier that he was willing to entertain a PEP to restore __cmp__, so I've attempted to create a draft PEP, posted here: http://www.dwheeler.com/misc/pep-cmp.

Re: [Python-3000] __bool__ in 2.6?

2007-10-29 Thread Guido van Rossum
2007/10/29, James Thiele <[EMAIL PROTECTED]>: > So just to clarify: > 2.5 __nonzero__ only > 2.6 __nonzero__ first, then __bool__ (if patch submitted) > 3.x __bool__ first, then __nonzero__ > > Is this correct? No. 3.x tests __bool__ only. > On 10/29/07, Guido van Rossum <[EMAIL PROTECTED]> wrote

Re: [Python-3000] __bool__ in 2.6?

2007-10-29 Thread Fred Drake
On Oct 29, 2007, at 2:51 PM, Guido van Rossum wrote: > Makes sense, if you change the 3.x rule to > > 3.x __bool__ only. Even better! I think I'm going to like 3.0 if I ever get a chance to use it. ;-) -Fred -- Fred Drake ___ Python-3000

Re: [Python-3000] bug in i/o module buffering?

2007-10-29 Thread Bill Janssen
> I'm asking about b because the error message "TypeError: 'slice' > object does not support item deletion" would suggest that b is a slice > object. I agree that doesn't sound very likely given the code > though... :-( Could you step through this using pdb and investigate > some more? Perhaps ther

Re: [Python-3000] socket GC worries

2007-10-29 Thread Bill Janssen
> The SocketCloser class wasn't written with > the SSL use case in mind. I don't think it's just SSL. The problem is that it explicitly counts calls to "close()". So if you let the GC sweep up after you, that close() just doesn't get called, the circular refs persist, and the resource doesn't g

Re: [Python-3000] Please re-add __cmp__ to python 3000

2007-10-29 Thread Adam Olsen
On 10/29/07, David A. Wheeler <[EMAIL PROTECTED]> wrote: > I think several postings have explained better than I have on why __cmp__ is > still very valuable. (See below.) > > Guido van Rossum posted earlier that he was willing to entertain a PEP to > restore __cmp__, so I've attempted to create

Re: [Python-3000] socket GC worries

2007-10-29 Thread Bill Janssen
> Actually, I'm still up for tweaks to the I/O model if it solves a real > problem, as long as most of the high-level APIs stay the same (there > simply is too much code that expects those to behave a certain way). > > I don't quite understand what you mean by inverted though. I'm actually thinkin

Re: [Python-3000] socket GC worries

2007-10-29 Thread Guido van Rossum
2007/10/29, Bill Janssen <[EMAIL PROTECTED]>: > > Actually, I'm still up for tweaks to the I/O model if it solves a real > > problem, as long as most of the high-level APIs stay the same (there > > simply is too much code that expects those to behave a certain way). > > > > I don't quite understand

Re: [Python-3000] socket GC worries

2007-10-29 Thread Guido van Rossum
2007/10/29, Bill Janssen <[EMAIL PROTECTED]>: > > The SocketCloser class wasn't written with > > the SSL use case in mind. > > I don't think it's just SSL. The problem is that it explicitly counts > calls to "close()". So if you let the GC sweep up after you, that > close() just doesn't get calle

Re: [Python-3000] Please re-add __cmp__ to python 3000

2007-10-29 Thread Guido van Rossum
I'm a bit too busy to look into this right now; I hope one or two more rounds of feedback on the PEP will get it into a state where I can review it more easily. Having a patch to go with it would be immensely helpful as well (in fact I'd say that without a patch it's unlikely to happen). --Guido

Re: [Python-3000] Please re-add __cmp__ to python 3000

2007-10-29 Thread Steven Bethard
On 10/29/07, David A. Wheeler <[EMAIL PROTECTED]> wrote: > I think several postings have explained better than I have on why __cmp__ is > still very valuable. (See below.) > > Guido van Rossum posted earlier that he was willing to entertain a PEP to > restore __cmp__, so I've attempted to create

Re: [Python-3000] socket GC worries

2007-10-29 Thread Bill Janssen
> Really? AFAIK everyone who opens a socket calls it. Sorry, I meant only a handful (10?) in the standard library. > I'd be okay with calling the class Socket and having a factory > function named socket though. Ah, good idea. Bill ___ Python-3000 mai

Re: [Python-3000] 3K bytes I/O?

2007-10-29 Thread Gregory P. Smith
And for non-unicode inputs the code should use the PEP 3118 buffer API rather than PyBytes_ or PyString_ or whatnot. On 10/26/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > 2007/10/26, Bill Janssen <[EMAIL PROTECTED]>: > > I'm looking at the Py3K SSL code, and have a question: > > > > What's

Re: [Python-3000] Please re-add __cmp__ to python 3000

2007-10-29 Thread Greg Ewing
David A. Wheeler wrote: > Greg Ewing stated "Why not provide a __richcmp__ method that directly connects > with the corresponding type slot? > It _seems_ to me that this is the same as "__cmp__", No, it's not -- a __richcmp__ method would take an extra argument specifying which of the six compari

Re: [Python-3000] __bool__ in 2.6?

2007-10-29 Thread Greg Ewing
James Thiele wrote: > 3.x __bool__ first, then __nonzero__ Does 3.x need __nonzero__ at all? -- Greg ___ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/opt

Re: [Python-3000] socket GC worries

2007-10-29 Thread Guido van Rossum
2007/10/29, Greg Ewing <[EMAIL PROTECTED]>: > I wrote: > > > Seems to me that a socket should already *be* a file, > > so it shouldn't need a makefile() method and you > > shouldn't have to mess around with filenos. > > Guido van Rossum wrote: > > > That model fits TCP/IP streams just fine, but

Re: [Python-3000] socket GC worries

2007-10-29 Thread Greg Ewing
I wrote: > Seems to me that a socket should already *be* a file, > so it shouldn't need a makefile() method and you > shouldn't have to mess around with filenos. Guido van Rossum wrote: > That model fits TCP/IP streams just fine, but doesn't work so well for > UDP and other odd socket types.

Re: [Python-3000] Please re-add __cmp__ to python 3000

2007-10-29 Thread Guido van Rossum
2007/10/29, Greg Ewing <[EMAIL PROTECTED]>: > David A. Wheeler wrote: > > Greg Ewing stated "Why not provide a __richcmp__ method that > > directly connects with the corresponding type slot? > > > It _seems_ to me that this is the same as "__cmp__", > > No, it's not -- a __richcmp__ method would ta

Re: [Python-3000] Please re-add __cmp__ to python 3000

2007-10-29 Thread Greg Ewing
Adam Olsen wrote: > It's not clear to me how many distinct operations you'd need though, > or how acceptable reflections would be. My intention was just to directly expose the tp_richcmp slot, so there would be six. To make things easier in the common case, there could perhaps be a utility functi

Re: [Python-3000] socket GC worries

2007-10-29 Thread Greg Ewing
Guido van Rossum wrote: > having read() > and write() methods on the _socket object is not the solution. It's not a necessary part of the solution, I agree. I just don't see what purpose is served by requiring an extra layer of wrapper between a socket and the other I/O layers. That's not a necess

Re: [Python-3000] socket GC worries

2007-10-29 Thread Greg Ewing
Guido van Rossum wrote: > That's because I don't find the synonyms a good idea. Even if it means that stream sockets then have the same interface as all other stream-like objects in the I/O system, so buffering layers can be used on them, etc.? That seems like a rather good reason to me. If you

Re: [Python-3000] socket GC worries

2007-10-29 Thread Guido van Rossum
2007/10/29, Greg Ewing <[EMAIL PROTECTED]>: > Guido van Rossum wrote: > > > That's because I don't find the synonyms a good idea. > > Even if it means that stream sockets then have the > same interface as all other stream-like objects in > the I/O system, so buffering layers can be used on > them,

Re: [Python-3000] Please re-add __cmp__ to python 3000

2007-10-29 Thread Adam Olsen
On 10/29/07, Greg Ewing <[EMAIL PROTECTED]> wrote: > Adam Olsen wrote: > > It's not clear to me how many distinct operations you'd need though, > > or how acceptable reflections would be. > > My intention was just to directly expose the tp_richcmp > slot, so there would be six. > > To make things e

Re: [Python-3000] Please re-add __cmp__ to python 3000

2007-10-29 Thread Jeffrey Yasskin
On 10/29/07, Steven Bethard <[EMAIL PROTECTED]> wrote: > On 10/29/07, David A. Wheeler <[EMAIL PROTECTED]> wrote: > > I think several postings have explained better than I have on why __cmp__ > > is still very valuable. (See below.) > > > > Guido van Rossum posted earlier that he was willing to e