diff options
author | Mark Shannon <mark@hotpy.org> | 2021-01-05 12:04:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-05 12:04:10 +0000 |
commit | ee9f98d9f4b881ee15868a836a2b99271df1bc0e (patch) | |
tree | 5f5a6b4cc99c86d7ee99cf0c8287cf601abd99a7 /Lib/test/test_frame.py | |
parent | e40e2a2cc94c554e7e245a8ca5a7432d31a95766 (diff) | |
download | cpython-git-ee9f98d9f4b881ee15868a836a2b99271df1bc0e.tar.gz |
bpo-42823: Fix frame lineno when frame.f_trace is set (GH-24099)
* Add test for frame.f_lineno with/without tracing.
* Make sure that frame.f_lineno is correct regardless of whether frame.f_trace is set.
* Update importlib
* Add NEWS
Diffstat (limited to 'Lib/test/test_frame.py')
-rw-r--r-- | Lib/test/test_frame.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_frame.py b/Lib/test/test_frame.py index a8696f011f..7ac37b6937 100644 --- a/Lib/test/test_frame.py +++ b/Lib/test/test_frame.py @@ -1,4 +1,5 @@ import re +import sys import types import unittest import weakref @@ -94,6 +95,26 @@ class ClearTest(unittest.TestCase): f.clear() self.assertTrue(endly) + def test_lineno_with_tracing(self): + def record_line(): + f = sys._getframe(1) + lines.append(f.f_lineno-f.f_code.co_firstlineno) + + def test(trace): + record_line() + if trace: + sys._getframe(0).f_trace = True + record_line() + record_line() + + expected_lines = [1, 4, 5] + lines = [] + test(False) + self.assertEqual(lines, expected_lines) + lines = [] + test(True) + self.assertEqual(lines, expected_lines) + @support.cpython_only def test_clear_refcycles(self): # .clear() doesn't leave any refcycle behind |