Patch / Bug Summary ___________________ Patches : 241 open ( -5) / 2315 closed ( +5) / 2556 total ( +0) Bugs : 711 open ( +6) / 3892 closed ( +5) / 4603 total (+11) RFE : 127 open ( +0) / 118 closed ( +0) / 245 total ( +0) Patches Closed ______________ urllib2 does not allow for absolute ftp paths (2003-10-03) http://python.org/sf/817379 closed by loewis tp_dealloc, threads and garbage collection (2004-02-09) http://python.org/sf/893566 closed by loewis urllib2 doesn't support non-anonymous ftp (2003-03-29) http://python.org/sf/711838 closed by loewis Updated .spec file. (2004-02-08) http://python.org/sf/892673 closed by loewis doctest handles comments incorrectly (2003-01-15) http://python.org/sf/668500 closed by tim_one New / Reopened Bugs ___________________ pyconfig.h is not placed in --includedir (2004-02-13) http://python.org/sf/896330 opened by Göran Uddeborg time.strftime crashes python (2004-02-15) http://python.org/sf/897625 opened by Tom Lynn test_strptime failures on FC2-test (2004-02-16) http://python.org/sf/897817 opened by Anthony Baxter db4 4.2 == :-( (test_anydbm and test_bsddb3) (2004-02-16) http://python.org/sf/897820 opened by Anthony Baxter Unknown color name on HP-UX (2004-02-16) http://python.org/sf/897872 opened by Richard Townsend pty.spawn() leaks file descriptors (2004-02-16) http://python.org/sf/897935 opened by James Henstridge strftime ignores date format on winxp (2004-02-17) http://python.org/sf/898253 opened by Matthew Sherborne symtable module crashes w/ coding declaration (2004-02-16) http://python.org/sf/898271 opened by Peter Åstrand Python 2.3 encoding parsing bug (2004-02-17) http://python.org/sf/898757 opened by Edward K. Ream test_threading (2003-08-19) http://python.org/sf/791542 reopened by bcannon 1==float('nan') (2004-02-17) http://python.org/sf/899109 opened by Arman Bostani Bugs Closed ___________ Inconsistent behavior of compressing the BZip2 format (2003-12-03) http://python.org/sf/853061 closed by niemeyer Unicode problem in os.path.getsize ? (2004-02-13) http://python.org/sf/896236 closed by loewis Core dump problems (2003-12-15) http://python.org/sf/860547 closed by rhettinger FAQ 2.3 slices not used (2004-02-02) http://python.org/sf/888829 closed by loewis test_threading (2003-08-19) http://python.org/sf/791542 closed by sleard1 Python 2.3 encoding parsing bug (2004-02-17) http://python.org/sf/898757 closed by loewis
[I apologize that I'm not adding this information to the bug report, but I'm not able to log into SF right now, the login page hangs while loading]
1==float('nan') (2004-02-17) http://python.org/sf/899109 opened by Arman Bostani
I'm sure Tim can explain this better, but what happens is this: 1 is
coerced to float for comparison. Then, the following C expression is
evaluated (Objects/floatobject.c:float_compare):
return (i < j) ? -1 : (i > j) ? 1 : 0;
Because NaN is "unordered", 1
[Jeff Epler]
[I apologize that I'm not adding this information to the bug report, but I'm not able to log into SF right now, the login page hangs while loading]
1==float('nan') (2004-02-17) http://python.org/sf/899109 opened by Arman Bostani
I'm sure Tim can explain this better,
No, but I can give a simpler <wink> explanation: it's all accidents, and can (and does) vary across platforms. To start with, that float('nan') didn't raise an exception is an accident already. On Windows, e.g., it does raise an exception.
but what happens is this: 1 is coerced to float for comparison. Then, the following C expression is evaluated Objects/floatobject.c:float_compare): return (i < j) ? -1 : (i > j) ? 1 : 0;
Provided you get that far, yes.
Because NaN is "unordered", 1
Another pair of accidents. C89 says nothing about the behavior of NaNs, so what any particular C compiler does with them is another pile of platform accidents. C99 doesn't require C implementations to do better than that, but does specify what C implementations must do if they *choose* to advertise support for 754 gimmicks (it's not mandatory).
and so python returns 0 from float_compare.
That is one possible outcome <wink>. Here on 2.3.3, but on Windows:
inf = 1e500 inf 1.#INF nan = inf-inf nan -1.#IND cmp(1, nan) -1 cmp(nan, 1) -1 1 == nan False nan == nan False nan < nan True 1 < nan True nan < 1 True inf < nan True nan < inf True
That's under MSVC 6. I know an earlier version of the MS compiler gave different results. BTW, non-accidental support for IEEE-754 oddballs (infs, NaNs, signed zeroes) is a wishlist item in PEP 42. Come next year, that standard will be 20 years old -- yet basically unusable despite near-universal HW support because languages just won't play along (in fairness, "playing along" in SW isn't easy, and nobody will pay for it -- how the HW manufacturers got roped into it remains something of a mystery to me, cuz it's not cheap or easy in HW either).
Tim, Thanks for reminding me that this all varies from machine to machine. I guess that what I was trying to say in my message is this: On my platform, I get the same result. Here's why. The term "unordered" came from me reading an x86 architecture reference and trying to use the same words the grown-ups use. It's too bad you can get infinity and nan other than by using float('os-specific mumbo-jumbo'), because if that weren't the case we could just force Python's syntax for floating-point literals on the argument to float(), never passing it to the platform atof() if it doesn't conform. That would, uh, completely solve all problems python programmers ever encounter with floats. Jeff
[Jeff Epler]
Thanks for reminding me that this all varies from machine to machine. I guess that what I was trying to say in my message is this:
On my platform, I get the same result. Here's why.
The term "unordered" came from me reading an x86 architecture reference and trying to use the same words the grown-ups use.
That manual got "unordered" from the IEEE-754 floating point standard, and it's a fine word to use. The problem is that the 754 standard (which also goes under a number of different names now) has no defined relationship to the C89 standard, so when talking about C code it doesn't matter at all what the 754 standard says: "unordered" just isn't a C89 concept. 754 does have a defined relationship to the newer C99 standard.
It's too bad you can get infinity and nan other than by using float('os-specific mumbo-jumbo'), because if that weren't the case we could just force Python's syntax for floating-point literals on the argument to float(), never passing it to the platform atof() if it doesn't conform. That would, uh, completely solve all problems python programmers ever encounter with floats.
It would be easier to just remove floats from Python for 2.4 <wink>.
Jeff Epler
[I apologize that I'm not adding this information to the bug report, but I'm not able to log into SF right now, the login page hangs while loading]
1==float('nan') (2004-02-17) http://python.org/sf/899109 opened by Arman Bostani
I'm sure Tim can explain this better, but what happens is this: 1 is coerced to float for comparison. Then, the following C expression is evaluated (Objects/floatobject.c:float_compare): return (i < j) ? -1 : (i > j) ? 1 : 0;
Would it make (more) sense to implement rich comparisons for floats? I'm not enthusiastic about the patch that got pasted into the bug report. Cheers, mwh -- [1]For those of you who aren't aware "tossing" is a euphamism for, well, vigourously rubbing your love pole. You understand? Flogging the dolphin. Stretching the chicken's neck. Waving your magic wand. Basically, wanking. -- Just another Morfans SDA update
[Michael Hudson]
Would it make (more) sense to implement rich comparisons for floats?
Not much. There are 32 distinct theoretical binary comparison operators under 754 semantics (16 for which subset of {<, =, >, unordered} you're interested in, and then each of those comes in two flavors depending on whether you want a signaling NaN comparand to, or not to, raise an exception), and the standard "recommends" implementing something like 26 of them.
I'm not enthusiastic about the patch that got pasted into the bug report.
That's dead on arrival -- apart from the dubious semantics it's trying to invent, it doesn't even work under MSVC 6 (which I've explained in the bug report). There's no reliable cross-platform C support for any of this stuff, therefore there's nothing Python can do about 754 oddballs without masses of platform-specific code (see fpectlmodule.c for a taste of that approach).
"Tim Peters"
[Michael Hudson]
Would it make (more) sense to implement rich comparisons for floats?
Not much.
But a little bit? It might at least make the results closer to what the underlying C compiler does (modulo bugs in same, of course).
There are 32 distinct theoretical binary comparison operators under 754 semantics (16 for which subset of {<, =, >, unordered} you're interested in, and then each of those comes in two flavors depending on whether you want a signaling NaN comparand to, or not to, raise an exception), and the standard "recommends" implementing something like 26 of them.
Well, we don't want an SNaN to S, Python has no concept of unordered. That's down to 8. We don't care about the improper subsets of {<, =, >}. That's 6. Rich comparisons.
I'm not enthusiastic about the patch that got pasted into the bug report.
That's dead on arrival -- apart from the dubious semantics it's trying to invent, it doesn't even work under MSVC 6 (which I've explained in the bug report). There's no reliable cross-platform C support for any of this stuff, therefore there's nothing Python can do about 754 oddballs without masses of platform-specific code (see fpectlmodule.c for a taste of that approach).
I realise it's a game of "pick your surprise", but the case mentioned in the bug report is particularly, well, surprising. Cheers, mwh -- "Also, does the simple algorithm you used in Cyclops have a name?" "Not officially, but it answers to "hey, dumb-ass!" -- Neil Schemenauer and Tim Peters, 23 Feb 2001
[Michael Hudson]
Would it make (more) sense to implement rich comparisons for floats?
[Tim]
Not much.
[Michael]
But a little bit? It might at least make the results closer to what the underlying C compiler does (modulo bugs in same, of course).
The intended behavior of NaNs is covered precisely by standards. Moving Python's nonsense behavior closer to the platform C's nonsense behavior doesn't scream "useful" to me. But I don't object to it either, if someone can't think of something better to do with their time <wink>. At least gcc users would get something much closer to what the standard intends (although their Python wouldn't be portable in these respects). OTOH, by pure accident, NaN==NaN *happens* to return the intended False today under Windows Python, and if that's changed, via rich comparison, to return True (which MSVC returns for the C expression NaN==NaN), then we've also managed to break currently-working code on Windows. 754 really isn't friendly to half-assed support.
"Tim Peters"
[Michael Hudson]
Would it make (more) sense to implement rich comparisons for floats?
[Tim]
Not much.
[Michael]
But a little bit? It might at least make the results closer to what the underlying C compiler does (modulo bugs in same, of course).
The intended behavior of NaNs is covered precisely by standards. Moving Python's nonsense behavior closer to the platform C's nonsense behavior doesn't scream "useful" to me.
As you say below, it helps with gcc (which more-or-less claims C99 support of late, so no great surprise).
But I don't object to it either, if someone can't think of something better to do with their time <wink>.
Heh. See the patch I just attached to the report :-)
At least gcc users would get something much closer to what the standard intends (although their Python wouldn't be portable in these respects). OTOH, by pure accident, NaN==NaN *happens* to return the intended False today under Windows Python, and if that's changed, via rich comparison, to return True (which MSVC returns for the C expression NaN==NaN), then we've also managed to break currently-working code on Windows.
Is MSVC 7 any different here? I did try to poke around msdn.microsoft.com and found: This version of Visual C++ is not conformant with the C99 standard. which (a) was in a section about the library specifically and (b) doesn't answer the question. Oh, hang on: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndeepc/htm... suggests (very much) that this *has* changed. But "someone" should check (I can't). (I certainly wasn't proposing this change for release23-maint).
754 really isn't friendly to half-assed support.
Indeed. But I think were the underlying compiler implements C99 semantics, it's unfriendly of Python to hide them. Cheers, mwh -- Ignoring the rules in the FAQ: 1" slice in spleen and prevention of immediate medical care. -- Mark C. Langston, asr
[Tim]
At least gcc users would get something much closer to what the standard intends (although their Python wouldn't be portable in these respects). OTOH, by pure accident, NaN==NaN *happens* to return the intended False today under Windows Python, and if that's changed, via rich comparison, to return True (which MSVC returns for the C expression NaN==NaN), then we've also managed to break currently-working code on Windows.
[Michael Hudson]
Is MSVC 7 any different here? I did try to poke around msdn.microsoft.com and found:
This version of Visual C++ is not conformant with the C99 standard.
which (a) was in a section about the library specifically and (b) doesn't answer the question. Oh, hang on:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndeepc/htm l/deep05282002.asp
suggests (very much) that this *has* changed. But "someone" should check (I can't).
I don't have 7 running here either, but that article flat-out says NaN comparisons work correctly now. I believe it -- after all, it's published on a Microsoft site, and so is reviewed by 79 major governments for lawsuit fodder <wink>.
(I certainly wasn't proposing this change for release23-maint).
We (Python) never promised anything about NaN behavior, so I don't really care if the "currently working" (by perverse accident) NaN==NaN result changes under MSVC 6.
754 really isn't friendly to half-assed support.
Indeed. But I think were the underlying compiler implements C99 semantics, it's unfriendly of Python to hide them.
That gets more involved; e.g., float operations should never raise exceptions then, not even division by 0 (although real 754 support includes ways to control whether exceptions get raised). I'm +1 on applying the patch for 2.4 regardless.
"Tim Peters"
(I certainly wasn't proposing this change for release23-maint).
We (Python) never promised anything about NaN behavior, so I don't really care if the "currently working" (by perverse accident) NaN==NaN result changes under MSVC 6.
I do: I don't think we should change much behaviour short of segfaulting. But I'm at the conservative end of this spectrum[1]; if someone else wants to backport it, I won't howl.
754 really isn't friendly to half-assed support.
Indeed. But I think were the underlying compiler implements C99 semantics, it's unfriendly of Python to hide them.
That gets more involved; e.g., float operations should never raise exceptions then, not even division by 0 (although real 754 support includes ways to control whether exceptions get raised).
I meant in the context of comparisons.
I'm +1 on applying the patch for 2.4 regardless.
Done! Cheers, mwh [1] Possibly because I have more sympathy for the patch monkey than most, having worn that particular hat for a time :-) -- ARTHUR: But which is probably incapable of drinking the coffee. -- The Hitch-Hikers Guide to the Galaxy, Episode 6
participants (4)
-
Jeff Epler
-
Kurt B. Kaiser
-
Michael Hudson
-
Tim Peters