diff options
| author | Mark Dickinson <dickinsm@gmail.com> | 2008-01-21 21:54:47 (GMT) | 
|---|---|---|
| committer | Mark Dickinson <dickinsm@gmail.com> | 2008-01-21 21:54:47 (GMT) | 
| commit | 2bebadfe517c8c3c5a24f246eb44b5fa9dfc2cf3 (patch) | |
| tree | e3135aa1d1c6174cde600d3fba6579dd831a9362 /Python/compile.c | |
| parent | 78d50ccdf93d98d39fa7ec741a401d6bf2db815a (diff) | |
| download | cpython-2bebadfe517c8c3c5a24f246eb44b5fa9dfc2cf3.zip cpython-2bebadfe517c8c3c5a24f246eb44b5fa9dfc2cf3.tar.gz cpython-2bebadfe517c8c3c5a24f246eb44b5fa9dfc2cf3.tar.bz2  | |
Issue 1678380:  fix a bug identifying -0.0 and 0.0
Diffstat (limited to 'Python/compile.c')
| -rw-r--r-- | Python/compile.c | 15 | 
1 files changed, 14 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c index ce19aa9..0e824ca 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1567,7 +1567,20 @@ compiler_add_o(struct compiler *c, PyObject *dict, PyObject *o)  	Py_ssize_t arg;  	/* necessary to make sure types aren't coerced (e.g., int and long) */ -	t = PyTuple_Pack(2, o, o->ob_type); +        /* _and_ to distinguish 0.0 from -0.0 e.g. on IEEE platforms */ +        if (PyFloat_Check(o)) { +            double d = PyFloat_AS_DOUBLE(o); +            unsigned char* p = (unsigned char*) &d; +            /* all we need is to make the tuple different in either the 0.0 +             * or -0.0 case from all others, just to avoid the "coercion". +             */ +            if (*p==0 && p[sizeof(double)-1]==0) +                t = PyTuple_Pack(3, o, o->ob_type, Py_None); +            else +	        t = PyTuple_Pack(2, o, o->ob_type); +        } else { +	    t = PyTuple_Pack(2, o, o->ob_type); +        }  	if (t == NULL)  	    return -1;  | 
