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

Skip to content

Commit 26fa57a

Browse files
traceback: update for py311 (#7886)
1 parent 0b7df3b commit 26fa57a

2 files changed

Lines changed: 45 additions & 6 deletions

File tree

stdlib/traceback.pyi

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ def clear_frames(tb: TracebackType) -> None: ...
9696
def walk_stack(f: FrameType | None) -> Iterator[tuple[FrameType, int]]: ...
9797
def walk_tb(tb: TracebackType | None) -> Iterator[tuple[FrameType, int]]: ...
9898

99+
if sys.version_info >= (3, 11):
100+
class _ExceptionPrintContext:
101+
def __init__(self) -> None: ...
102+
def indent(self) -> str: ...
103+
def emit(self, text_gen: str | Iterable[str], margin_char: str | None = ...) -> Generator[str, None, None]: ...
104+
99105
class TracebackException:
100106
__cause__: TracebackException
101107
__context__: TracebackException
@@ -107,7 +113,34 @@ class TracebackException:
107113
text: str
108114
offset: int
109115
msg: str
110-
if sys.version_info >= (3, 10):
116+
if sys.version_info >= (3, 11):
117+
def __init__(
118+
self,
119+
exc_type: type[BaseException],
120+
exc_value: BaseException,
121+
exc_traceback: TracebackType | None,
122+
*,
123+
limit: int | None = ...,
124+
lookup_lines: bool = ...,
125+
capture_locals: bool = ...,
126+
compact: bool = ...,
127+
max_group_width: int = ...,
128+
max_group_depth: int = ...,
129+
_seen: set[int] | None = ...,
130+
) -> None: ...
131+
@classmethod
132+
def from_exception(
133+
cls: type[Self],
134+
exc: BaseException,
135+
*,
136+
limit: int | None = ...,
137+
lookup_lines: bool = ...,
138+
capture_locals: bool = ...,
139+
compact: bool = ...,
140+
max_group_width: int = ...,
141+
max_group_depth: int = ...,
142+
) -> Self: ...
143+
elif sys.version_info >= (3, 10):
111144
def __init__(
112145
self,
113146
exc_type: type[BaseException],
@@ -148,9 +181,16 @@ class TracebackException:
148181
) -> Self: ...
149182

150183
def __eq__(self, other: object) -> bool: ...
151-
def format(self, *, chain: bool = ...) -> Generator[str, None, None]: ...
184+
if sys.version_info >= (3, 11):
185+
def format(self, *, chain: bool = ..., _ctx: _ExceptionPrintContext | None = ...) -> Generator[str, None, None]: ...
186+
else:
187+
def format(self, *, chain: bool = ...) -> Generator[str, None, None]: ...
188+
152189
def format_exception_only(self) -> Generator[str, None, None]: ...
153190

191+
if sys.version_info >= (3, 11):
192+
def print(self, *, file: SupportsWrite[str] | None = ..., chain: bool = ...) -> None: ...
193+
154194
class FrameSummary(Iterable[Any]):
155195
if sys.version_info >= (3, 11):
156196
def __init__(
@@ -213,4 +253,7 @@ class StackSummary(list[FrameSummary]):
213253
) -> StackSummary: ...
214254
@classmethod
215255
def from_list(cls, a_list: list[_PT]) -> StackSummary: ...
256+
if sys.version_info >= (3, 11):
257+
def format_frame_summary(self, frame_summary: FrameSummary) -> str: ...
258+
216259
def format(self) -> list[str]: ...

tests/stubtest_allowlists/py311.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ symtable.SymbolTable.has_exec
9797
sys.UnraisableHookArgs # Not exported from sys
9898
sys.exception
9999
tkinter._VersionInfoType.__doc__
100-
traceback.StackSummary.format_frame_summary
101-
traceback.TracebackException.__init__
102-
traceback.TracebackException.format
103-
traceback.TracebackException.print
104100
types.ClassMethodDescriptorType.__get__
105101
types.CodeType.co_exceptiontable
106102
types.CodeType.co_qualname

0 commit comments

Comments
 (0)