diff options
author | Raymond Hettinger <python@rcn.com> | 2005-02-23 13:37:55 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2005-02-23 13:37:55 (GMT) |
commit | e63a078635f58ff66b3feec44bb9a29926127ee5 (patch) | |
tree | c992f30e404344e4c432709edb9c2f9c5617b59a /Python/compile.c | |
parent | 71dcc3e9b4b0d4fe25c36e0a8370eae9ab85da56 (diff) | |
download | cpython-e63a078635f58ff66b3feec44bb9a29926127ee5.zip cpython-e63a078635f58ff66b3feec44bb9a29926127ee5.tar.gz cpython-e63a078635f58ff66b3feec44bb9a29926127ee5.tar.bz2 |
Preserve sign of -0.0 when result is run through marshal.
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c index 6e68d0f..71e90f7 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); |