We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b49f95d commit d41cf78Copy full SHA for d41cf78
1 file changed
Lib/test/test_monitoring.py
@@ -3,7 +3,6 @@
3
import collections
4
import dis
5
import functools
6
-import inspect
7
import math
8
import operator
9
import sys
@@ -1718,15 +1717,10 @@ def func(s: str) -> int:
1718
1717
return 0
1719
1720
def callback(code, from_, to):
1721
- frame = inspect.currentframe()
1722
- while frame and frame.f_code is not code:
1723
- frame = frame.f_back
1724
-
1725
- if frame:
1726
- self.assertIs(frame.f_code, code)
1727
- # try get and set frame.f_lineno
1728
- l = frame.f_lineno
1729
- frame.f_lineno = l
+ frame = sys._getframe(0)
+ old = frame.f_lineno
+ # try set frame.f_lineno
+ frame.f_lineno = frame.f_lineno
1730
1731
sys.monitoring.set_local_events(TEST_TOOL, func.__code__, E.BRANCH_LEFT)
1732
sys.monitoring.register_callback(TEST_TOOL, E.BRANCH_LEFT, callback)
0 commit comments