From 15f07ac1e56a43de9466d1d845eb4ea0cbd72be9 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sat, 5 Aug 2023 12:08:23 -0500 Subject: [PATCH] Add slots to exceptions --- trio/_core/_exceptions.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/trio/_core/_exceptions.py b/trio/_core/_exceptions.py index bdc7b31c21..d4e74aec86 100644 --- a/trio/_core/_exceptions.py +++ b/trio/_core/_exceptions.py @@ -14,6 +14,8 @@ class TrioInternalError(Exception): """ + __slots__ = () + class RunFinishedError(RuntimeError): """Raised by `trio.from_thread.run` and similar functions if the @@ -21,10 +23,14 @@ class RunFinishedError(RuntimeError): """ + __slots__ = () + class WouldBlock(Exception): """Raised by ``X_nowait`` functions if ``X`` would block.""" + __slots__ = () + class Cancelled(BaseException, metaclass=NoPublicConstructor): """Raised by blocking calls if the surrounding scope has been cancelled. @@ -59,6 +65,8 @@ class Cancelled(BaseException, metaclass=NoPublicConstructor): """ + __slots__ = () + def __str__(self) -> str: return "Cancelled" @@ -73,6 +81,8 @@ class BusyResourceError(Exception): """ + __slots__ = () + class ClosedResourceError(Exception): """Raised when attempting to use a resource after it has been closed. @@ -86,6 +96,8 @@ class ClosedResourceError(Exception): """ + __slots__ = () + class BrokenResourceError(Exception): """Raised when an attempt to use a resource fails due to external @@ -102,6 +114,8 @@ class BrokenResourceError(Exception): """ + __slots__ = () + class EndOfChannel(Exception): """Raised when trying to receive from a :class:`trio.abc.ReceiveChannel` @@ -110,3 +124,5 @@ class EndOfChannel(Exception): This is analogous to an "end-of-file" condition, but for channels. """ + + __slots__ = ()