summaryrefslogtreecommitdiffstats
path: root/Lib/functools.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-06-18 08:34:57 (GMT)
committerGitHub <noreply@github.com>2022-06-18 08:34:57 (GMT)
commitf9433fff476aa13af9cb314fcc6962055faa4085 (patch)
tree1e8510f86eda5b339ab35c30127d00d5bf6d57f4 /Lib/functools.py
parent084023ccbeb3bf54a2e19873c6a4b0bec7b617f6 (diff)
downloadcpython-f9433fff476aa13af9cb314fcc6962055faa4085.zip
cpython-f9433fff476aa13af9cb314fcc6962055faa4085.tar.gz
cpython-f9433fff476aa13af9cb314fcc6962055faa4085.tar.bz2
gh-89828: Do not relay the __class__ attribute in GenericAlias (#93754)
list[int].__class__ returned type, and isinstance(list[int], type) returned True. It caused numerous problems in code that checks isinstance(x, type).
Diffstat (limited to 'Lib/functools.py')
-rw-r--r--Lib/functools.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/functools.py b/Lib/functools.py
index cd5666d..43ead51 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -843,12 +843,11 @@ def singledispatch(func):
return get_origin(cls) in {Union, types.UnionType}
def _is_valid_dispatch_type(cls):
- if isinstance(cls, type) and not isinstance(cls, GenericAlias):
+ if isinstance(cls, type):
return True
from typing import get_args
return (_is_union_type(cls) and
- all(isinstance(arg, type) and not isinstance(arg, GenericAlias)
- for arg in get_args(cls)))
+ all(isinstance(arg, type) for arg in get_args(cls)))
def register(cls, func=None):
"""generic_func.register(cls, func) -> func