Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 71dcc3e commit e63a078Copy full SHA for e63a078
1 file changed
Python/compile.c
@@ -545,7 +545,7 @@ fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
545
static int
546
fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts)
547
{
548
- PyObject *newconst, *v;
+ PyObject *newconst=NULL, *v;
549
int len_consts, opcode;
550
551
/* Pre-conditions */
@@ -557,7 +557,9 @@ fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts)
557
opcode = codestr[3];
558
switch (opcode) {
559
case UNARY_NEGATIVE:
560
- newconst = PyNumber_Negative(v);
+ /* Preserve the sign of -0.0 */
561
+ if (PyObject_IsTrue(v) == 1)
562
+ newconst = PyNumber_Negative(v);
563
break;
564
case UNARY_CONVERT:
565
newconst = PyObject_Repr(v);
0 commit comments