mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[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:
parent
04273adae0
commit
f885c7d9b9
4 changed files with 68 additions and 11 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue