summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorAlex Waygood <Alex.Waygood@Gmail.com>2023-05-18 23:34:40 (GMT)
committerGitHub <noreply@github.com>2023-05-18 23:34:40 (GMT)
commitf7835fc7e9617cefd87e72002916e258f589c857 (patch)
tree4cbc2335ea681412ebe6ea8710920cdaef8465c3 /Lib/typing.py
parentaab2a366b7d6a5c123bc8d23d66db4d2277dfa09 (diff)
downloadcpython-f7835fc7e9617cefd87e72002916e258f589c857.zip
cpython-f7835fc7e9617cefd87e72002916e258f589c857.tar.gz
cpython-f7835fc7e9617cefd87e72002916e258f589c857.tar.bz2
gh-74690: Don't set special protocol attributes on non-protocol subclasses of protocols (#104622)
Don't set special protocol attributes on non-protocol subclasses of protocols
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 91b5fe5..b60eb94 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -1779,12 +1779,13 @@ class _ProtocolMeta(ABCMeta):
# but is necessary for several reasons...
def __init__(cls, *args, **kwargs):
super().__init__(*args, **kwargs)
- cls.__protocol_attrs__ = _get_protocol_attrs(cls)
- # PEP 544 prohibits using issubclass()
- # with protocols that have non-method members.
- cls.__callable_proto_members_only__ = all(
- callable(getattr(cls, attr, None)) for attr in cls.__protocol_attrs__
- )
+ if getattr(cls, "_is_protocol", False):
+ cls.__protocol_attrs__ = _get_protocol_attrs(cls)
+ # PEP 544 prohibits using issubclass()
+ # with protocols that have non-method members.
+ cls.__callable_proto_members_only__ = all(
+ callable(getattr(cls, attr, None)) for attr in cls.__protocol_attrs__
+ )
def __subclasscheck__(cls, other):
if (