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

Meyer, Tony T.A.Meyer@massey.ac.nz
Thu, 24 Jul 2003 18:17:56 +1200


> So when the marshalled representation of 0.001 is loaded under
> "german" LC_NUMERIC here, we get back exactly 0.0.  I'm not=20
> sure why.

When I call "marshal.dumps(0.1)" from AsyncDialog (or anywhere in the
Outlook code) I get "f\x030.0", which fits with what you have.

> So the obvious <wink> answers are:

(Glad you posted this - I was wading through the progress of marshalling
(PyOS_snprintf etc) and getting rapidly lost).

> 1. When LC_NUMERIC is "german", MS C's atof() stops at the first
>    period it sees.

This is the case:
"""
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    float f;
    setlocale(LC_NUMERIC, "german");
    f =3D atof("0.1");
    printf("%f\n", f);
}
"""

Gives me with gcc version 3.2 20020927 (prerelease):
	0.100000
Gives me with Microsoft C++ Builder (I don't have Visual C++ handy, but
I suppose it would be the same):
      0,00000

The help file for Builder does say that this is the correct behaviour -
it will stop when it finds an unrecognised character - here '.' is
unrecognised (because we are in German), so it stops.

Does this then mean that this is a Python bug?  Or because Python tells
us not to change the c locale and we (Outlook) are, it's our
fault/problem?

Presumably what we'll have to do for a solution is just what Mark is
doing now - find the correct place to put a call that (re)sets the c
locale to English.

=3DTony Meyer