[3.14] gh-135429: Fix the argument mismatch in lsprof throw event (GH-135442) (#135446)

gh-135429: Fix the argument mismatch in lsprof throw event (GH-135442)
(cherry picked from commit b03309fe5f)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
This commit is contained in:
Miss Islington (bot) 2025-06-13 00:13:36 +02:00 committed by GitHub
parent 04273adae0
commit f885c7d9b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 68 additions and 11 deletions

View file

@ -125,21 +125,22 @@ class CProfileTest(ProfileTest):
"""
gh-106152
generator.throw() should trigger a call in cProfile
In the any() call below, there should be two entries for the generator:
* one for the call to __next__ which gets a True and terminates any
* one when the generator is garbage collected which will effectively
do a throw.
"""
def gen():
yield
pr = self.profilerclass()
pr.enable()
any(a == 1 for a in (1, 2))
g = gen()
try:
g.throw(SyntaxError)
except SyntaxError:
pass
pr.disable()
pr.create_stats()
for func, (cc, nc, _, _, _) in pr.stats.items():
if func[2] == "<genexpr>":
self.assertEqual(cc, 1)
self.assertEqual(nc, 1)
self.assertTrue(any("throw" in func[2] for func in pr.stats.keys())),
def test_bad_descriptor(self):
# gh-132250