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 4d81ac9 commit 5e54796Copy full SHA for 5e54796
1 file changed
Python/compile.c
@@ -570,7 +570,13 @@ try_set_conversion(unsigned char *codestr, PyObject *consts)
570
return 0;
571
}
572
573
- /* Append new constant onto consts list.*/
+ /* Append new constant onto consts list or replace existing constant
574
+ if there are no other references to it.*/
575
+ if (constant->ob_refcnt == 1) {
576
+ PyList_SET_ITEM(consts, arg, newconst);
577
+ Py_DECREF(constant);
578
+ return 1;
579
+ }
580
len_consts = PyList_GET_SIZE(consts);
581
if (PyList_Append(consts, newconst)) {
582
Py_DECREF(newconst);
0 commit comments