Skip to content

Commit de0fc0a

Browse files
authored
traceback: py313 updates (#12032)
1 parent 10bf03b commit de0fc0a

File tree

2 files changed

+55
-24
lines changed

2 files changed

+55
-24
lines changed

stdlib/@tests/stubtest_allowlists/py313.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,7 @@ tkinter.Text.count
204204
tkinter.Wm.wm_attributes
205205
tkinter.tix
206206
trace.CoverageResults.write_results
207-
traceback.StackSummary.should_show_carets
208-
traceback.TracebackException.__init__
209-
traceback.TracebackException.exc_type
210-
traceback.TracebackException.exc_type_str
211-
traceback.TracebackException.format_exception_only
212-
traceback.format_exception_only
207+
traceback.StackSummary.should_show_carets # https://github.com/python/cpython/pull/112670#discussion_r1613952301
213208
turtle.RawTurtle.settiltangle
214209
turtle.__all__
215210
turtle.settiltangle

stdlib/traceback.pyi

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from _typeshed import SupportsWrite, Unused
33
from collections.abc import Generator, Iterable, Iterator, Mapping
44
from types import FrameType, TracebackType
55
from typing import Any, Literal, overload
6-
from typing_extensions import Self, TypeAlias
6+
from typing_extensions import Self, TypeAlias, deprecated
77

88
__all__ = [
99
"extract_stack",
@@ -85,7 +85,13 @@ def format_list(extracted_list: Iterable[FrameSummary | _FrameSummaryTuple]) ->
8585
# undocumented
8686
def print_list(extracted_list: Iterable[FrameSummary | _FrameSummaryTuple], file: SupportsWrite[str] | None = None) -> None: ...
8787

88-
if sys.version_info >= (3, 10):
88+
if sys.version_info >= (3, 13):
89+
@overload
90+
def format_exception_only(exc: BaseException | None, /, *, show_group: bool = False) -> list[str]: ...
91+
@overload
92+
def format_exception_only(exc: Unused, /, value: BaseException | None, *, show_group: bool = False) -> list[str]: ...
93+
94+
elif sys.version_info >= (3, 10):
8995
@overload
9096
def format_exception_only(exc: BaseException | None, /) -> list[str]: ...
9197
@overload
@@ -111,13 +117,20 @@ class TracebackException:
111117
__context__: TracebackException
112118
__suppress_context__: bool
113119
stack: StackSummary
114-
exc_type: type[BaseException]
115120
filename: str
116121
lineno: int
117122
text: str
118123
offset: int
119124
msg: str
120-
if sys.version_info >= (3, 11):
125+
if sys.version_info >= (3, 13):
126+
@property
127+
def exc_type_str(self) -> str: ...
128+
@property
129+
@deprecated("Deprecated in 3.13. Use exc_type_str instead.")
130+
def exc_type(self) -> type[BaseException] | None: ...
131+
else:
132+
exc_type: type[BaseException]
133+
if sys.version_info >= (3, 13):
121134
def __init__(
122135
self,
123136
exc_type: type[BaseException],
@@ -130,20 +143,24 @@ class TracebackException:
130143
compact: bool = False,
131144
max_group_width: int = 15,
132145
max_group_depth: int = 10,
146+
save_exc_type: bool = True,
133147
_seen: set[int] | None = None,
134148
) -> None: ...
135-
@classmethod
136-
def from_exception(
137-
cls,
138-
exc: BaseException,
149+
elif sys.version_info >= (3, 11):
150+
def __init__(
151+
self,
152+
exc_type: type[BaseException],
153+
exc_value: BaseException,
154+
exc_traceback: TracebackType | None,
139155
*,
140156
limit: int | None = None,
141157
lookup_lines: bool = True,
142158
capture_locals: bool = False,
143159
compact: bool = False,
144160
max_group_width: int = 15,
145161
max_group_depth: int = 10,
146-
) -> Self: ...
162+
_seen: set[int] | None = None,
163+
) -> None: ...
147164
elif sys.version_info >= (3, 10):
148165
def __init__(
149166
self,
@@ -157,6 +174,20 @@ class TracebackException:
157174
compact: bool = False,
158175
_seen: set[int] | None = None,
159176
) -> None: ...
177+
else:
178+
def __init__(
179+
self,
180+
exc_type: type[BaseException],
181+
exc_value: BaseException,
182+
exc_traceback: TracebackType | None,
183+
*,
184+
limit: int | None = None,
185+
lookup_lines: bool = True,
186+
capture_locals: bool = False,
187+
_seen: set[int] | None = None,
188+
) -> None: ...
189+
190+
if sys.version_info >= (3, 11):
160191
@classmethod
161192
def from_exception(
162193
cls,
@@ -166,19 +197,21 @@ class TracebackException:
166197
lookup_lines: bool = True,
167198
capture_locals: bool = False,
168199
compact: bool = False,
200+
max_group_width: int = 15,
201+
max_group_depth: int = 10,
169202
) -> Self: ...
170-
else:
171-
def __init__(
172-
self,
173-
exc_type: type[BaseException],
174-
exc_value: BaseException,
175-
exc_traceback: TracebackType | None,
203+
elif sys.version_info >= (3, 10):
204+
@classmethod
205+
def from_exception(
206+
cls,
207+
exc: BaseException,
176208
*,
177209
limit: int | None = None,
178210
lookup_lines: bool = True,
179211
capture_locals: bool = False,
180-
_seen: set[int] | None = None,
181-
) -> None: ...
212+
compact: bool = False,
213+
) -> Self: ...
214+
else:
182215
@classmethod
183216
def from_exception(
184217
cls, exc: BaseException, *, limit: int | None = None, lookup_lines: bool = True, capture_locals: bool = False
@@ -190,7 +223,10 @@ class TracebackException:
190223
else:
191224
def format(self, *, chain: bool = True) -> Generator[str, None, None]: ...
192225

193-
def format_exception_only(self) -> Generator[str, None, None]: ...
226+
if sys.version_info >= (3, 13):
227+
def format_exception_only(self, *, show_group: bool = False, _depth: int = 0) -> Generator[str, None, None]: ...
228+
else:
229+
def format_exception_only(self) -> Generator[str, None, None]: ...
194230

195231
if sys.version_info >= (3, 11):
196232
def print(self, *, file: SupportsWrite[str] | None = None, chain: bool = True) -> None: ...

0 commit comments

Comments
 (0)