[Python-Dev] Re: RE: [Spambayes] Question (or possibly a bug report)

Tim Peters tim.one@comcast.net
Fri, 25 Jul 2003 22:20:21 -0400

[Terry Reedy]
> Lib Manual 3.19 says clearly that the marshal format for a specific
> release is system independent and tranportable.  It includes floats as
> one of the types so supported.  If, as I have gathered from this
> thread, the format for floats is actually, under certain
> circumstances, whimsy-dependent, I think a warning should be added to
> the doc until the bug is fixed.

The warning is there, but it's in the locale module docs (see the "For
extension writers and programs that embed Python" section).  It's a
documented requirement that LC_NUMERIC be "C" when using Python, and
violating that is akin to dividing by 0 in C:  nothing is defined if you
break the rules.  The .pyc problem is only one of the things that can go
wrong, and is getting all the attention here just because it *is* going
wrong in the spambayes Outlook addin.

Note that you can't fall into this trap running a pure Python program.  It
requires that you also run some non-Python code in the same process that
mucks with C runtime state in a forbidden-by-Python way.  Python can't
*stop* non-Python C code from screwing up the locale, it can only document
(and does document) that Python may not work as intended if that occurs.

Since Python is functioning as designed and documented in such cases, it's
hard to sell this as "a bug" in a convincing way.  As Python spreads into
more embedded contexts, though, the consequences of this design decision
(really more of a no-brainer that looks like "a decision" in hindsight:  C's
horrid locale gimmicks didn't exist when these parts of Python were first
written!) justify arguing for a friendlier (to embedding) design.