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

Skip to content
Closed
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
23 changes: 15 additions & 8 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from collections.abc import Callable
from types import FunctionType, NoneType
from typing import Any, Final, NamedTuple, NoReturn, Literal, overload
from typing import TYPE_CHECKING, Any, Final, NamedTuple, NoReturn, Literal, overload

# TODO:
#
Expand Down Expand Up @@ -2554,17 +2554,24 @@ def get_displayname(self, i):

class LandMine:
# try to access any
def __init__(self, message):
def __init__(self, message: str) -> None:
self.__message__ = message

def __repr__(self):
def __repr__(self) -> str:
return '<LandMine ' + repr(self.__message__) + ">"

def __getattribute__(self, name):
if name in ('__repr__', '__message__'):
return super().__getattribute__(name)
# raise RuntimeError(repr(name))
fail("Stepped on a land mine, trying to access attribute " + repr(name) + ":\n" + self.__message__)
# Type checkers wouldn't check attribute access on instances of this class properly
# if they saw it had a __getattribute__ method,
# so pretend to type checkers that the __getattribute__ method doesn't exist
if not TYPE_CHECKING:
def __getattribute__(self, name):
if name in ('__repr__', '__message__'):
return super().__getattribute__(name)
# raise RuntimeError(repr(name))
fail(
f"Stepped on a land mine, trying to access attribute "
f"{name!r}:\n{self.__message__}"
)


def add_c_converter(f, name=None):
Expand Down