Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions stdlib/@tests/test_cases/check_tkinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import sys
import tkinter
import traceback
import types
from typing import Optional, Tuple
from typing_extensions import assert_type


def custom_handler(exc: type[BaseException], val: BaseException, tb: types.TracebackType | None) -> None:
print("oh no")
root = tkinter.Tk()
tkinter.Tk.report_callback_exception(root, TypeError, TypeError("no"), None)


root = tkinter.Tk()
root.report_callback_exception = traceback.print_exception
root.report_callback_exception = custom_handler
class App(tkinter.Tk):
def report_callback_exception(self, exc: type[BaseException], val: BaseException, tb: types.TracebackType | None) -> None:
print("oh no")


def foo(x: int, y: str) -> None:
Expand Down
20 changes: 20 additions & 0 deletions stdlib/@tests/test_cases/check_tkinter_method_assign.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# mypy: disable-error-code="method-assign"
from __future__ import annotations

import tkinter
import traceback
import types


def custom_handler(exc: type[BaseException], val: BaseException, tb: types.TracebackType | None) -> None:
print("oh no")


def custom_wrong_handler(exc: BaseException, val: BaseException, tb: types.TracebackType | None) -> None:
print("oh no")


root = tkinter.Tk()
root.report_callback_exception = traceback.print_exception
root.report_callback_exception = custom_handler
root.report_callback_exception = custom_wrong_handler # type: ignore
3 changes: 2 additions & 1 deletion stdlib/tkinter/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,8 @@ class Tk(Misc, Wm):
config = configure
def destroy(self) -> None: ...
def readprofile(self, baseName: str, className: str) -> None: ...
report_callback_exception: Callable[[type[BaseException], BaseException, TracebackType | None], object]
def report_callback_exception(self, exc: type[BaseException], val: BaseException, tb: TracebackType | None, /) -> object: ...

# Tk has __getattr__ so that tk_instance.foo falls back to tk_instance.tk.foo
# Please keep in sync with _tkinter.TkappType.
# Some methods are intentionally missing because they are inherited from Misc instead.
Expand Down
Loading