summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-12-19 16:59:51 (GMT)
committerGitHub <noreply@github.com>2024-12-19 16:59:51 (GMT)
commitd2f1d917e8b3d2dd8f35495c7632a32688883332 (patch)
tree334558f483e0f41d80924973d16b68354bf95b82 /Objects
parent7b811d0562a0bf7433165785f1549ac199610f8b (diff)
downloadcpython-d2f1d917e8b3d2dd8f35495c7632a32688883332.zip
cpython-d2f1d917e8b3d2dd8f35495c7632a32688883332.tar.gz
cpython-d2f1d917e8b3d2dd8f35495c7632a32688883332.tar.bz2
GH-122548: Implement branch taken and not taken events for sys.monitoring (GH-122564)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/codeobject.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index eb8de13..ae232ca 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -2197,6 +2197,12 @@ code_linesiterator(PyObject *self, PyObject *Py_UNUSED(args))
return (PyObject *)new_linesiterator(code);
}
+static PyObject *
+code_branchesiterator(PyCodeObject *code, PyObject *Py_UNUSED(args))
+{
+ return _PyInstrumentation_BranchesIterator(code);
+}
+
/*[clinic input]
@text_signature "($self, /, **changes)"
code.replace
@@ -2337,6 +2343,7 @@ code__varname_from_oparg_impl(PyCodeObject *self, int oparg)
static struct PyMethodDef code_methods[] = {
{"__sizeof__", code_sizeof, METH_NOARGS},
{"co_lines", code_linesiterator, METH_NOARGS},
+ {"co_branches", (PyCFunction)code_branchesiterator, METH_NOARGS},
{"co_positions", code_positionsiterator, METH_NOARGS},
CODE_REPLACE_METHODDEF
CODE__VARNAME_FROM_OPARG_METHODDEF