mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
[3.12] gh-126220: Fix crash on calls to _lsprof.Profiler methods with 0 args (backportable) (GH-126271) (#126311)
gh-126220: Fix crash on calls to `_lsprof.Profiler` methods with 0 args (backportable) (GH-126271)
(cherry picked from commit 28b148fb32)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
parent
ce5bb3ca85
commit
b5c19bdba8
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