Skip to content

Commit 4103350

Browse files
committed
fix tests
1 parent 69fd874 commit 4103350

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

.cspell.dict/python-more.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ PYTHONHASHSEED
178178
PYTHONHOME
179179
PYTHONINSPECT
180180
PYTHONINTMAXSTRDIGITS
181+
PYTHONNODEBUGRANGES
181182
PYTHONNOUSERSITE
182183
PYTHONOPTIMIZE
183184
PYTHONPATH

Lib/test/test_code.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,6 @@ def test_co_positions_artificial_instructions(self):
425425
]
426426
)
427427

428-
# TODO: RUSTPYTHON; no_debug_ranges option not supported
429-
@unittest.expectedFailure
430428
def test_endline_and_columntable_none_when_no_debug_ranges(self):
431429
# Make sure that if `-X no_debug_ranges` is used, there is
432430
# minimal debug info
@@ -442,8 +440,6 @@ def f():
442440
""")
443441
assert_python_ok('-X', 'no_debug_ranges', '-c', code)
444442

445-
# TODO: RUSTPYTHON; no_debug_ranges option not supported
446-
@unittest.expectedFailure
447443
def test_endline_and_columntable_none_when_no_debug_ranges_env(self):
448444
# Same as above but using the environment variable opt out.
449445
code = textwrap.dedent("""

Lib/test/test_zipimport.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,8 @@ def doTraceback(self, module):
724724
else:
725725
raise AssertionError("This ought to be impossible")
726726

727+
# TODO: RUSTPYTHON; empty caret lines from equal col/end_col
728+
@unittest.expectedFailure
727729
def testTraceback(self):
728730
files = {TESTMOD + ".py": (NOW, raise_src)}
729731
self.doTest(None, files, TESTMOD, call=self.doTraceback)

crates/vm/src/builtins/frame.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ impl Frame {
6464

6565
#[pygetset]
6666
pub fn f_lineno(&self) -> usize {
67-
self.current_location().line.get()
67+
// If lasti is 0, execution hasn't started yet - use first line number
68+
// Similar to PyCode_Addr2Line which returns co_firstlineno for addr_q < 0
69+
if self.lasti() == 0 {
70+
self.code.first_line_number.map(|n| n.get()).unwrap_or(1)
71+
} else {
72+
self.current_location().line.get()
73+
}
6874
}
6975

7076
#[pygetset]

0 commit comments

Comments
 (0)