Skip to content

Commit 4f21d52

Browse files
authored
Fix sys.getdxp() when configured with --enable-pystats. (GH-31251)
1 parent b0662ae commit 4f21d52

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Python/ceval.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7459,14 +7459,30 @@ _Py_GetDXProfile(PyObject *self, PyObject *args)
74597459
int i;
74607460
PyObject *l = PyList_New(257);
74617461
if (l == NULL) return NULL;
7462-
for (i = 0; i < 257; i++) {
7462+
for (i = 0; i < 256; i++) {
74637463
PyObject *x = getarray(_py_stats.opcode_stats[i].pair_count);
74647464
if (x == NULL) {
74657465
Py_DECREF(l);
74667466
return NULL;
74677467
}
74687468
PyList_SET_ITEM(l, i, x);
74697469
}
7470+
PyObject *counts = PyList_New(256);
7471+
if (counts == NULL) {
7472+
Py_DECREF(l);
7473+
return NULL;
7474+
}
7475+
for (i = 0; i < 256; i++) {
7476+
PyObject *x = PyLong_FromUnsignedLongLong(
7477+
_py_stats.opcode_stats[i].execution_count);
7478+
if (x == NULL) {
7479+
Py_DECREF(counts);
7480+
Py_DECREF(l);
7481+
return NULL;
7482+
}
7483+
PyList_SET_ITEM(counts, i, x);
7484+
}
7485+
PyList_SET_ITEM(l, 256, counts);
74707486
return l;
74717487
}
74727488

0 commit comments

Comments
 (0)