mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
gh-126220: Fix crash on calls to _lsprof.Profiler
methods with 0 args (backportable) (#126271)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
parent
72dd4714f9
commit
28b148fb32
3 changed files with 42 additions and 0 deletions
|
@ -30,6 +30,22 @@ class CProfileTest(ProfileTest):
|
|||
|
||||
self.assertEqual(cm.unraisable.exc_type, TypeError)
|
||||
|
||||
def test_crash_with_not_enough_args(self):
|
||||
# gh-126220
|
||||
import _lsprof
|
||||
|
||||
for profile in [_lsprof.Profiler(), cProfile.Profile()]:
|
||||
for method in [
|
||||
"_pystart_callback",
|
||||
"_pyreturn_callback",
|
||||
"_ccall_callback",
|
||||
"_creturn_callback",
|
||||
]:
|
||||
with self.subTest(profile=profile, method=method):
|
||||
method_obj = getattr(profile, method)
|
||||
with self.assertRaises(TypeError):
|
||||
method_obj() # should not crash
|
||||
|
||||
def test_evil_external_timer(self):
|
||||
# gh-120289
|
||||
# Disabling profiler in external timer should not crash
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue