mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
[3.13] gh-132250: Clear error in lsprof callback when method descriptor raises an excep… (GH-132251) (#132281)
gh-132250: Clear error in lsprof callback when method descriptor raises an excep… (GH-132251)
(cherry picked from commit ab64130b57)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
This commit is contained in:
parent
67ebb399eb
commit
10fe658f34
3 changed files with 10 additions and 0 deletions
|
|
@ -139,6 +139,14 @@ def test_throw(self):
|
|||
self.assertEqual(cc, 1)
|
||||
self.assertEqual(nc, 1)
|
||||
|
||||
def test_bad_descriptor(self):
|
||||
# gh-132250
|
||||
# cProfile should not crash when the profiler callback fails to locate
|
||||
# the actual function of a method.
|
||||
with self.profilerclass() as prof:
|
||||
with self.assertRaises(TypeError):
|
||||
bytes.find(str())
|
||||
|
||||
|
||||
class TestCommandLine(unittest.TestCase):
|
||||
def test_sort(self):
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Fixed the :exc:`SystemError` in :mod:`cProfile` when locating the actual C function of a method raises an exception.
|
||||
|
|
@ -652,6 +652,7 @@ PyObject* get_cfunc_from_callable(PyObject* callable, PyObject* self_arg, PyObje
|
|||
PyObject *meth = Py_TYPE(callable)->tp_descr_get(
|
||||
callable, self_arg, (PyObject*)Py_TYPE(self_arg));
|
||||
if (meth == NULL) {
|
||||
PyErr_Clear();
|
||||
return NULL;
|
||||
}
|
||||
if (PyCFunction_Check(meth)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue