mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
Preserve sign of -0.0 when result is run through marshal.
This commit is contained in:
parent
71dcc3e9b4
commit
e63a078635
1 changed files with 4 additions and 2 deletions
|
@ -545,7 +545,7 @@ fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
|
||||||
static int
|
static int
|
||||||
fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts)
|
fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts)
|
||||||
{
|
{
|
||||||
PyObject *newconst, *v;
|
PyObject *newconst=NULL, *v;
|
||||||
int len_consts, opcode;
|
int len_consts, opcode;
|
||||||
|
|
||||||
/* Pre-conditions */
|
/* Pre-conditions */
|
||||||
|
@ -557,7 +557,9 @@ fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts)
|
||||||
opcode = codestr[3];
|
opcode = codestr[3];
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case UNARY_NEGATIVE:
|
case UNARY_NEGATIVE:
|
||||||
newconst = PyNumber_Negative(v);
|
/* Preserve the sign of -0.0 */
|
||||||
|
if (PyObject_IsTrue(v) == 1)
|
||||||
|
newconst = PyNumber_Negative(v);
|
||||||
break;
|
break;
|
||||||
case UNARY_CONVERT:
|
case UNARY_CONVERT:
|
||||||
newconst = PyObject_Repr(v);
|
newconst = PyObject_Repr(v);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue