diff options
author | Mark Shannon <mark@hotpy.org> | 2021-04-29 18:28:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 18:28:50 (GMT) |
commit | 088a15c49d99ecb4c3bef93f8f40dd513c6cae3b (patch) | |
tree | 547dc91a32ba1c1885bc9b8cc1ae7f66e1722f5e /Lib/test | |
parent | 2fd928c8c1328424130cb9c51fc02ad5f9a66328 (diff) | |
download | cpython-088a15c49d99ecb4c3bef93f8f40dd513c6cae3b.zip cpython-088a15c49d99ecb4c3bef93f8f40dd513c6cae3b.tar.gz cpython-088a15c49d99ecb4c3bef93f8f40dd513c6cae3b.tar.bz2 |
bpo-43933: Show frame.f_lineno as None, rather than -1, if there is no line number. (GH-25717)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_exceptions.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 590935c..3810108 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -2081,7 +2081,10 @@ class PEP626Tests(unittest.TestCase): while t.tb_next: t = t.tb_next frame = t.tb_frame - self.assertEqual(frame.f_lineno-frame.f_code.co_firstlineno, line) + if line is None: + self.assertEqual(frame.f_lineno, line) + else: + self.assertEqual(frame.f_lineno-frame.f_code.co_firstlineno, line) def test_lineno_after_raise_simple(self): def simple(): @@ -2153,6 +2156,12 @@ class PEP626Tests(unittest.TestCase): pass self.lineno_after_raise(after_with, 2) + def test_missing_lineno_shows_as_none(self): + def f(): + 1/0 + self.lineno_after_raise(f, 1) + f.__code__ = f.__code__.replace(co_linetable=b'\x04\x80\xff\x80') + self.lineno_after_raise(f, None) if __name__ == '__main__': unittest.main() |