From 1c666d464c844792dd992f9b14e54171297cde3f Mon Sep 17 00:00:00 2001 From: Chen Li Date: Fri, 8 Mar 2019 14:31:20 -0800 Subject: [PATCH 1/2] [traceback] Expose print_list method in traceback for python3. Add print_list to traceback based on https://github.com/python/cpython/blob/master/Lib/traceback.py#L19. --- stdlib/2and3/traceback.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/2and3/traceback.pyi b/stdlib/2and3/traceback.pyi index 3b77df2613e4..0be8ebfd034f 100644 --- a/stdlib/2and3/traceback.pyi +++ b/stdlib/2and3/traceback.pyi @@ -36,6 +36,7 @@ if sys.version_info >= (3, 5): def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> StackSummary: ... def format_list(extracted_list: List[FrameSummary]) -> List[str]: ... + def print_list(extracted_list: List[FrameSummary], file: Optional[IO[str]] = ...) -> None: ... else: def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[_PT]: ... def extract_stack(f: Optional[FrameType] = ..., From 532297568191e24d552aa937fb3284fee92e1929 Mon Sep 17 00:00:00 2001 From: Chen Li Date: Mon, 11 Mar 2019 12:58:28 -0700 Subject: [PATCH 2/2] [traceback] Fix print_list method in traceback for python3. The patch contains two minor fixes: 1) Mark the method as '# undocumented' 2) Change 'file' argument type from IO to _Writable --- stdlib/2and3/traceback.pyi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stdlib/2and3/traceback.pyi b/stdlib/2and3/traceback.pyi index 0be8ebfd034f..b10a923d38ba 100644 --- a/stdlib/2and3/traceback.pyi +++ b/stdlib/2and3/traceback.pyi @@ -1,6 +1,6 @@ # Stubs for traceback -from typing import Any, Dict, Generator, IO, Iterator, List, Mapping, Optional, Tuple, Type, Iterable +from typing import Any, Dict, Generator, IO, Iterator, List, Mapping, Optional, Protocol, Tuple, Type, Iterable from types import FrameType, TracebackType import sys @@ -36,7 +36,10 @@ if sys.version_info >= (3, 5): def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> StackSummary: ... def format_list(extracted_list: List[FrameSummary]) -> List[str]: ... - def print_list(extracted_list: List[FrameSummary], file: Optional[IO[str]] = ...) -> None: ... + class _Writer(Protocol): + def write(self, s: str) -> Any: ... + # undocumented + def print_list(extracted_list: List[FrameSummary], file: Optional[_Writer] = ...) -> None: ... else: def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[_PT]: ... def extract_stack(f: Optional[FrameType] = ...,