From: Raymond Hettinger Date: Wed, 23 Feb 2005 13:37:55 +0000 (+0000) Subject: Preserve sign of -0.0 when result is run through marshal. X-Git-Tag: v2.5a0~1999 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e63a078635f58ff66b3feec44bb9a29926127ee5;p=python Preserve sign of -0.0 when result is run through marshal. --- diff --git a/Python/compile.c b/Python/compile.c index 6e68d0fd5d..71e90f7e21 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -545,7 +545,7 @@ fold_binops_on_constants(unsigned char *codestr, PyObject *consts) static int fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts) { - PyObject *newconst, *v; + PyObject *newconst=NULL, *v; int len_consts, opcode; /* Pre-conditions */ @@ -557,7 +557,9 @@ fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts) opcode = codestr[3]; switch (opcode) { case UNARY_NEGATIVE: - newconst = PyNumber_Negative(v); + /* Preserve the sign of -0.0 */ + if (PyObject_IsTrue(v) == 1) + newconst = PyNumber_Negative(v); break; case UNARY_CONVERT: newconst = PyObject_Repr(v);