diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-07-23 22:44:43 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-23 22:44:43 (GMT) |
| commit | 257c413cd16ddabcedde413288d0bb93bf872da7 (patch) | |
| tree | 766e4ff685653627d0c1405f1ad7a0c7c3bd5efa /Python | |
| parent | d7c67e0acac81649e7e2d7e86fe1fc54d51f96f9 (diff) | |
| download | cpython-257c413cd16ddabcedde413288d0bb93bf872da7.zip cpython-257c413cd16ddabcedde413288d0bb93bf872da7.tar.gz cpython-257c413cd16ddabcedde413288d0bb93bf872da7.tar.bz2 | |
[3.12] gh-122029: Log call events in sys.setprofile when it's a method with c function (GH-122072) (GH-122206)
gh-122029: Log call events in sys.setprofile when it's a method with c function (GH-122072)
Log call events in sys.setprofile when it is a method with a C function.
(cherry picked from commit e91ef13861e88c27aed51a24e58d1dcc855a01dc)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/legacy_tracing.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Python/legacy_tracing.c b/Python/legacy_tracing.c index 43fa591..4a6565b 100644 --- a/Python/legacy_tracing.c +++ b/Python/legacy_tracing.c @@ -103,6 +103,19 @@ sys_profile_call_or_return( Py_DECREF(meth); return res; } + else if (Py_TYPE(callable) == &PyMethod_Type) { + // CALL instruction will grab the function from the method, + // so if the function is a C function, the return event will + // be emitted. However, CALL event happens before CALL + // instruction, so we need to handle this case here. + PyObject* func = PyMethod_GET_FUNCTION(callable); + if (func == NULL) { + return NULL; + } + if (PyCFunction_Check(func)) { + return call_profile_func(self, func); + } + } Py_RETURN_NONE; } |
