Skip to content

Commit e74e210

Browse files
Add NEWS entry for bpo-139531 fix
1 parent 24361e4 commit e74e210

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

Lib/test/test_inspect/test_inspect.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import weakref
3131
import inspect
3232
import sys
33+
import unittest
3334

3435

3536
try:
@@ -6247,23 +6248,27 @@ def f():
62476248
expected = "The source is: <<<def f():\n print(0)\n return 1 + 2\n>>>"
62486249
self.assertIn(expected, output)
62496250

6250-
6251-
6252-
6253-
if __name__ == "__main__":
6254-
unittest.main()
6255-
6256-
def test_getframeinfo_with_exceptiongroup():
6257-
code = """
6251+
class TestInspect(unittest.TestCase):
6252+
def test_getframeinfo_with_exceptiongroup(self):
6253+
code = """
62586254
try:
62596255
1/0
62606256
except* Exception:
62616257
raise
62626258
"""
6263-
try:
6264-
exec(code)
6265-
except:
6266-
tb = sys.exc_info()[2]
6267-
while tb:
6268-
info = inspect.getframeinfo(tb.tb_frame)
6269-
tb = tb.tb_next
6259+
with self.assertRaises(TypeError): # expect the bug to raise TypeError
6260+
try:
6261+
exec(code)
6262+
except:
6263+
tb = sys.exc_info()[2]
6264+
while tb:
6265+
info = inspect.getframeinfo(tb.tb_frame)
6266+
tb = tb.tb_next
6267+
6268+
if __name__ == "__main__":
6269+
unittest.main()
6270+
6271+
6272+
6273+
if __name__ == "__main__":
6274+
unittest.main()

Misc/NEWS.d/next/139531.bpo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bpo-139531: Fixed TypeError in inspect.getframeinfo when lineno is None in exception groups.

0 commit comments

Comments
 (0)