From: Tomas R. Date: Tue, 3 Dec 2024 16:08:39 +0000 (+0100) Subject: gh-127347: Document `traceback.print_list` (#127348) X-Git-Tag: v3.14.0a3~137 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8ba9f5bca9c0ce6130e1f4ba761a68f74f8457d0;p=thirdparty%2FPython%2Fcpython.git gh-127347: Document `traceback.print_list` (#127348) Previously, `traceback.print_list` didn't have a documentation entry and was not exposed in `traceback.__all__`. Now it has a documentation entry and is exposed in `__all__`. --- diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst index 100a92b73d54..8f94fc448f24 100644 --- a/Doc/library/traceback.rst +++ b/Doc/library/traceback.rst @@ -157,6 +157,13 @@ Module-Level Functions arguments have the same meaning as for :func:`print_stack`. +.. function:: print_list(extracted_list, file=None) + + Print the list of tuples as returned by :func:`extract_tb` or + :func:`extract_stack` as a formatted stack trace to the given file. + If *file* is ``None``, the output is written to :data:`sys.stderr`. + + .. function:: format_list(extracted_list) Given a list of tuples or :class:`FrameSummary` objects as returned by diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index ec69412f5511..ea8d9f2137ac 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -4488,9 +4488,8 @@ class MiscTest(unittest.TestCase): def test_all(self): expected = set() - denylist = {'print_list'} for name in dir(traceback): - if name.startswith('_') or name in denylist: + if name.startswith('_'): continue module_object = getattr(traceback, name) if getattr(module_object, '__module__', None) == 'traceback': diff --git a/Lib/traceback.py b/Lib/traceback.py index f73149271b9b..6367c00e4d4b 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -15,7 +15,7 @@ __all__ = ['extract_stack', 'extract_tb', 'format_exception', 'format_tb', 'print_exc', 'format_exc', 'print_exception', 'print_last', 'print_stack', 'print_tb', 'clear_frames', 'FrameSummary', 'StackSummary', 'TracebackException', - 'walk_stack', 'walk_tb'] + 'walk_stack', 'walk_tb', 'print_list'] # # Formatting and printing lists of traceback lines. diff --git a/Misc/NEWS.d/next/Documentation/2024-11-27-22-56-48.gh-issue-127347.xyddWS.rst b/Misc/NEWS.d/next/Documentation/2024-11-27-22-56-48.gh-issue-127347.xyddWS.rst new file mode 100644 index 000000000000..79b3faa3d0d3 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2024-11-27-22-56-48.gh-issue-127347.xyddWS.rst @@ -0,0 +1 @@ +Publicly expose :func:`traceback.print_list` in :attr:`!traceback.__all__`.