[Python-checkins] cpython: Issue #23883: Add missing entries to traceback.__all__.

berker.peksag python-checkins at python.org
Wed Apr 8 08:46:58 CEST 2015


https://hg.python.org/cpython/rev/ebf3e6332a44
changeset:   95482:ebf3e6332a44
user:        Berker Peksag <berker.peksag at gmail.com>
date:        Wed Apr 08 09:47:14 2015 +0300
summary:
  Issue #23883: Add missing entries to traceback.__all__.

files:
  Lib/test/test_traceback.py |  23 ++++++++++++++++-------
  Lib/traceback.py           |   5 +++--
  2 files changed, 19 insertions(+), 9 deletions(-)


diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -6,8 +6,7 @@
 import sys
 import unittest
 import re
-from test.support import run_unittest, Error, captured_output
-from test.support import TESTFN, unlink, cpython_only
+from test.support import TESTFN, Error, captured_output, unlink, cpython_only
 from test.script_helper import assert_python_ok
 import textwrap
 
@@ -593,7 +592,7 @@
                 traceback.walk_stack(None), capture_locals=True, limit=1)
         s = some_inner(3, 4)
         self.assertEqual(
-            ['  File "' + __file__ + '", line 593, '
+            ['  File "' + __file__ + '", line 592, '
              'in some_inner\n'
              '    traceback.walk_stack(None), capture_locals=True, limit=1)\n'
              '    a = 1\n'
@@ -603,7 +602,6 @@
             ], s.format())
 
 
-
 class TestTracebackException(unittest.TestCase):
 
     def test_smoke(self):
@@ -732,8 +730,19 @@
         self.assertEqual(exc.stack[0].locals, None)
 
 
-def test_main():
-    run_unittest(__name__)
+class MiscTest(unittest.TestCase):
+
+    def test_all(self):
+        expected = set()
+        blacklist = {'print_list'}
+        for name in dir(traceback):
+            if name.startswith('_') or name in blacklist:
+                continue
+            module_object = getattr(traceback, name)
+            if getattr(module_object, '__module__', None) == 'traceback':
+                expected.add(name)
+        self.assertCountEqual(traceback.__all__, expected)
+
 
 if __name__ == "__main__":
-    test_main()
+    unittest.main()
diff --git a/Lib/traceback.py b/Lib/traceback.py
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -7,8 +7,9 @@
 __all__ = ['extract_stack', 'extract_tb', 'format_exception',
            'format_exception_only', 'format_list', 'format_stack',
            'format_tb', 'print_exc', 'format_exc', 'print_exception',
-           'print_last', 'print_stack', 'print_tb',
-           'clear_frames']
+           'print_last', 'print_stack', 'print_tb', 'clear_frames',
+           'FrameSummary', 'StackSummary', 'TracebackException',
+           'walk_stack', 'walk_tb']
 
 #
 # Formatting and printing lists of traceback lines.

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list