Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 664b43b

Browse files
committed
Re-running python with/without the -Qnew flag uses incorrectly optimized
bytecodes from the previously saved .pyc files. Fixed by disabling the static optimization of BINARY_DIVIDE between two constants.
1 parent 5a9fb3c commit 664b43b

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

Python/compile.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,9 @@ fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
468468
newconst = PyNumber_Multiply(v, w);
469469
break;
470470
case BINARY_DIVIDE:
471-
if (!_Py_QnewFlag) {
472-
newconst = PyNumber_Divide(v, w);
473-
break;
474-
}
475-
/* -Qnew is in effect: fall through to
476-
BINARY_TRUE_DIVIDE */
471+
/* XXX care is needed to fold this operation statically:
472+
the result might depend on the run-time presence of the -Qnew flag */
473+
return 0;
477474
case BINARY_TRUE_DIVIDE:
478475
newconst = PyNumber_TrueDivide(v, w);
479476
break;

0 commit comments

Comments
 (0)