Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 716b3d3

Browse files
committed
Issue #23883: Add missing entries to traceback.__all__.
1 parent cb6fdf2 commit 716b3d3

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

Lib/test/test_traceback.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import sys
77
import unittest
88
import re
9-
from test.support import run_unittest, Error, captured_output
10-
from test.support import TESTFN, unlink, cpython_only
9+
from test.support import TESTFN, Error, captured_output, unlink, cpython_only
1110
from test.script_helper import assert_python_ok
1211
import textwrap
1312

@@ -593,7 +592,7 @@ def some_inner(k, v):
593592
traceback.walk_stack(None), capture_locals=True, limit=1)
594593
s = some_inner(3, 4)
595594
self.assertEqual(
596-
[' File "' + __file__ + '", line 593, '
595+
[' File "' + __file__ + '", line 592, '
597596
'in some_inner\n'
598597
' traceback.walk_stack(None), capture_locals=True, limit=1)\n'
599598
' a = 1\n'
@@ -603,7 +602,6 @@ def some_inner(k, v):
603602
], s.format())
604603

605604

606-
607605
class TestTracebackException(unittest.TestCase):
608606

609607
def test_smoke(self):
@@ -732,8 +730,19 @@ def test_no_locals(self):
732730
self.assertEqual(exc.stack[0].locals, None)
733731

734732

735-
def test_main():
736-
run_unittest(__name__)
733+
class MiscTest(unittest.TestCase):
734+
735+
def test_all(self):
736+
expected = set()
737+
blacklist = {'print_list'}
738+
for name in dir(traceback):
739+
if name.startswith('_') or name in blacklist:
740+
continue
741+
module_object = getattr(traceback, name)
742+
if getattr(module_object, '__module__', None) == 'traceback':
743+
expected.add(name)
744+
self.assertCountEqual(traceback.__all__, expected)
745+
737746

738747
if __name__ == "__main__":
739-
test_main()
748+
unittest.main()

Lib/traceback.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
__all__ = ['extract_stack', 'extract_tb', 'format_exception',
88
'format_exception_only', 'format_list', 'format_stack',
99
'format_tb', 'print_exc', 'format_exc', 'print_exception',
10-
'print_last', 'print_stack', 'print_tb',
11-
'clear_frames']
10+
'print_last', 'print_stack', 'print_tb', 'clear_frames',
11+
'FrameSummary', 'StackSummary', 'TracebackException',
12+
'walk_stack', 'walk_tb']
1213

1314
#
1415
# Formatting and printing lists of traceback lines.

0 commit comments

Comments
 (0)