diff options
author | Tian Gao <gaogaotiantian@hotmail.com> | 2024-07-23 15:25:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-23 15:25:26 -0700 |
commit | e91ef13861e88c27aed51a24e58d1dcc855a01dc (patch) | |
tree | 51dc07c53bc50d877609d63385b07f120b980b9b /Python/legacy_tracing.c | |
parent | 41a91bd67f86c922f350894a797738038536e1c5 (diff) | |
download | cpython-e91ef13861e88c27aed51a24e58d1dcc855a01dc.tar.gz cpython-e91ef13861e88c27aed51a24e58d1dcc855a01dc.zip |
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.
Diffstat (limited to 'Python/legacy_tracing.c')
-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 1103d999dfa..9cc3af1f5e1 100644 --- a/Python/legacy_tracing.c +++ b/Python/legacy_tracing.c @@ -121,6 +121,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; } |