summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_typing.py
diff options
context:
space:
mode:
authorAlex Waygood <Alex.Waygood@Gmail.com>2023-06-05 14:10:49 (GMT)
committerGitHub <noreply@github.com>2023-06-05 14:10:49 (GMT)
commit08756dbba647440803d2ba4545ba0ab2f0cdfe1c (patch)
treea7ad7d87f7b66412790e143561fa34bb8ba2afb3 /Lib/test/test_typing.py
parent058b96053563bb5c413dc081eb8cc0916516525c (diff)
downloadcpython-08756dbba647440803d2ba4545ba0ab2f0cdfe1c.zip
cpython-08756dbba647440803d2ba4545ba0ab2f0cdfe1c.tar.gz
cpython-08756dbba647440803d2ba4545ba0ab2f0cdfe1c.tar.bz2
gh-105280: Ensure `isinstance([], collections.abc.Mapping)` always evaluates to `False` (#105281)
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r--Lib/test/test_typing.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index f6e0d20..1ad07b1 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -3,6 +3,7 @@ import collections
import collections.abc
from collections import defaultdict
from functools import lru_cache, wraps
+import gc
import inspect
import itertools
import pickle
@@ -2758,6 +2759,19 @@ class ProtocolTests(BaseTestCase):
with self.assertRaisesRegex(TypeError, only_classes_allowed):
issubclass(1, BadPG)
+ def test_isinstance_checks_not_at_whim_of_gc(self):
+ self.addCleanup(gc.enable)
+ gc.disable()
+
+ with self.assertRaisesRegex(
+ TypeError,
+ "Protocols can only inherit from other protocols"
+ ):
+ class Foo(collections.abc.Mapping, Protocol):
+ pass
+
+ self.assertNotIsInstance([], collections.abc.Mapping)
+
def test_issubclass_and_isinstance_on_Protocol_itself(self):
class C:
def x(self): pass