Skip to content

Commit 5813a81

Browse files
committed
gh-92810: Address review fixes
1 parent b294760 commit 5813a81

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Doc/whatsnew/3.15.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ abc
833833
* Reduce memory usage of :func:`issubclass` checks for classes inheriting abstract classes.
834834

835835
:class:`abc.ABCMeta` hook ``__subclasscheck__`` now includes
836-
a guard which is triggered then the hook is called from a parent class
836+
a guard which is triggered when the hook is called from a parent class
837837
(``issubclass(cls, RootClass)`` -> ``issubclass(cls, NestedClass)`` -> ...).
838838
This guard prevents adding ``cls`` to ``NestedClass`` positive and negative caches,
839839
preventing memory bloat in some cases (thousands of classes inherited from ABC).

Lib/test/test_abc.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import _py_abc
1313
from inspect import isabstract
1414

15+
1516
def test_factory(abc_ABCMeta, abc_get_cache_token):
1617
class TestLegacyAPI(unittest.TestCase):
1718

@@ -73,22 +74,22 @@ class TestABC(unittest.TestCase):
7374
def check_isinstance(self, obj, target_class):
7475
self.assertIsInstance(obj, target_class)
7576
self.assertIsInstance(obj, (target_class,))
76-
self.assertIsInstance(obj, target_class | target_class)
77+
self.assertIsInstance(obj, target_class | int)
7778

7879
def check_not_isinstance(self, obj, target_class):
7980
self.assertNotIsInstance(obj, target_class)
8081
self.assertNotIsInstance(obj, (target_class,))
81-
self.assertNotIsInstance(obj, target_class | target_class)
82+
self.assertNotIsInstance(obj, target_class | int)
8283

8384
def check_issubclass(self, klass, target_class):
8485
self.assertIsSubclass(klass, target_class)
8586
self.assertIsSubclass(klass, (target_class,))
86-
self.assertIsSubclass(klass, target_class | target_class)
87+
self.assertIsSubclass(klass, target_class | int)
8788

8889
def check_not_issubclass(self, klass, target_class):
8990
self.assertNotIsSubclass(klass, target_class)
9091
self.assertNotIsSubclass(klass, (target_class,))
91-
self.assertNotIsSubclass(klass, target_class | target_class)
92+
self.assertNotIsSubclass(klass, target_class | int)
9293

9394
def test_ABC_helper(self):
9495
# create an ABC using the helper class and perform basic checks

0 commit comments

Comments
 (0)