Skip to content

Commit 33b66f9

Browse files
CPython Developersyouknowone
authored andcommitted
Update test_monitoring from v3.14.3
1 parent 39263f9 commit 33b66f9

3 files changed

Lines changed: 195 additions & 49 deletions

File tree

Lib/test/test_monitoring.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,8 @@
1414
import test.support
1515
from test.support import import_helper, requires_specialization_ft, script_helper
1616

17-
# TODO: RUSTPYTHON - make _testcapi optional so other tests can run
18-
try:
19-
_testcapi = import_helper.import_module("_testcapi")
20-
except unittest.SkipTest:
21-
_testcapi = None
22-
try:
23-
_testinternalcapi = import_helper.import_module("_testinternalcapi")
24-
except unittest.SkipTest:
25-
_testinternalcapi = None
17+
_testcapi = import_helper.import_module("_testcapi")
18+
_testinternalcapi = import_helper.import_module("_testinternalcapi")
2619

2720
PAIR = (0,1)
2821

@@ -1235,6 +1228,7 @@ def func1():
12351228
('instruction', 'func1', 16),
12361229
('line', 'get_events', 11)])
12371230

1231+
@unittest.expectedFailure # TODO: RUSTPYTHON; - instruction offsets differ from CPython
12381232
def test_c_call(self):
12391233

12401234
def func2():
@@ -1260,6 +1254,7 @@ def func2():
12601254
('instruction', 'func2', 46),
12611255
('line', 'get_events', 11)])
12621256

1257+
@unittest.expectedFailure # TODO: RUSTPYTHON; - instruction offsets differ from CPython
12631258
def test_try_except(self):
12641259

12651260
def func3():
@@ -1557,6 +1552,7 @@ class BranchRightOffsetRecorder(JumpOffsetRecorder):
15571552
class TestBranchAndJumpEvents(CheckEvents):
15581553
maxDiff = None
15591554

1555+
@unittest.expectedFailure # TODO: RUSTPYTHON; - bytecode layout differs from CPython
15601556
def test_loop(self):
15611557

15621558
def func():
@@ -1622,6 +1618,7 @@ def whilefunc(n=0):
16221618
('branch left', 'func', 44, 50),
16231619
('branch right', 'func', 28, 70)])
16241620

1621+
@unittest.expectedFailure # TODO: RUSTPYTHON; - bytecode layout differs from CPython
16251622
def test_except_star(self):
16261623

16271624
class Foo:
@@ -1667,6 +1664,7 @@ def func():
16671664
('return', 'func', None),
16681665
('line', 'get_events', 11)])
16691666

1667+
@unittest.expectedFailure # TODO: RUSTPYTHON; - bytecode layout differs from CPython
16701668
def test_while_offset_consistency(self):
16711669

16721670
def foo(n=0):
@@ -1684,6 +1682,7 @@ def foo(n=0):
16841682
in_loop,
16851683
exit_loop])
16861684

1685+
@unittest.expectedFailure # TODO: RUSTPYTHON; - bytecode layout differs from CPython
16871686
def test_async_for(self):
16881687

16891688
def func():
@@ -1708,6 +1707,7 @@ async def foo():
17081707
('branch left', 'func', 12, 12)])
17091708

17101709

1710+
@unittest.expectedFailure # TODO: RUSTPYTHON; - bytecode layout differs from CPython
17111711
def test_match(self):
17121712

17131713
def func(v=1):
@@ -2248,6 +2248,7 @@ def test_func(recorder):
22482248

22492249
class TestMonitoringAtShutdown(unittest.TestCase):
22502250

2251+
@unittest.expectedFailure # TODO: RUSTPYTHON; - requires subprocess support
22512252
def test_monitoring_live_at_shutdown(self):
22522253
# gh-115832: An object destructor running during the final GC of
22532254
# interpreter shutdown triggered an infinite loop in the
@@ -2256,7 +2257,6 @@ def test_monitoring_live_at_shutdown(self):
22562257
script_helper.run_test_script(script)
22572258

22582259

2259-
@unittest.skipIf(_testcapi is None, "requires _testcapi") # TODO: RUSTPYTHON
22602260
class TestCApiEventGeneration(MonitoringTestBase, unittest.TestCase):
22612261

22622262
class Scope:

crates/codegen/src/compile.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3750,6 +3750,9 @@ impl Compiler {
37503750
is_async: bool,
37513751
funcflags: bytecode::MakeFunctionFlags,
37523752
) -> CompileResult<()> {
3753+
// Save source range so MAKE_FUNCTION gets the `def` line, not the body's last line
3754+
let saved_range = self.current_source_range;
3755+
37533756
// Always enter function scope
37543757
self.enter_function(name, parameters)?;
37553758
self.current_code_info()
@@ -3803,6 +3806,9 @@ impl Compiler {
38033806
let code = self.exit_scope();
38043807
self.ctx = prev_ctx;
38053808

3809+
// Restore source range so MAKE_FUNCTION is attributed to the `def` line
3810+
self.set_source_range(saved_range);
3811+
38063812
// Create function object with closure
38073813
self.make_closure(code, funcflags)?;
38083814

0 commit comments

Comments
 (0)