diff options
author | Mark Shannon <mark@hotpy.org> | 2022-02-10 12:14:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-10 12:14:57 (GMT) |
commit | 4f21d528f0fc29c861c5461c9fa60bc532b0d300 (patch) | |
tree | d1457a429cf246d840350238f27a6e8b7a7053f5 | |
parent | b0662ae5c83d8678506989cccbf7ba7bf61fea9d (diff) | |
download | cpython-4f21d528f0fc29c861c5461c9fa60bc532b0d300.zip cpython-4f21d528f0fc29c861c5461c9fa60bc532b0d300.tar.gz cpython-4f21d528f0fc29c861c5461c9fa60bc532b0d300.tar.bz2 |
Fix sys.getdxp() when configured with --enable-pystats. (GH-31251)
-rw-r--r-- | Python/ceval.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 958ca11..7e19043 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -7459,7 +7459,7 @@ _Py_GetDXProfile(PyObject *self, PyObject *args) int i; PyObject *l = PyList_New(257); if (l == NULL) return NULL; - for (i = 0; i < 257; i++) { + for (i = 0; i < 256; i++) { PyObject *x = getarray(_py_stats.opcode_stats[i].pair_count); if (x == NULL) { Py_DECREF(l); @@ -7467,6 +7467,22 @@ _Py_GetDXProfile(PyObject *self, PyObject *args) } PyList_SET_ITEM(l, i, x); } + PyObject *counts = PyList_New(256); + if (counts == NULL) { + Py_DECREF(l); + return NULL; + } + for (i = 0; i < 256; i++) { + PyObject *x = PyLong_FromUnsignedLongLong( + _py_stats.opcode_stats[i].execution_count); + if (x == NULL) { + Py_DECREF(counts); + Py_DECREF(l); + return NULL; + } + PyList_SET_ITEM(counts, i, x); + } + PyList_SET_ITEM(l, 256, counts); return l; } |