From 1313bf1083c389f36d984a889b9532b3847663ec Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 25 Sep 2024 22:42:25 -0700 Subject: [PATCH 1/2] gh-101100: Make __subclasses__ doctest stable Using a standard library class makes this test difficult to maintain as other tests and other parts of the stdlib may create subclasses, which may still be alive when this test runs depending on GC timing. --- Doc/reference/datamodel.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index a6348eda3891cc..6be4fe5ce1c5e3 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1109,8 +1109,10 @@ have the following two methods available: .. doctest:: - >>> int.__subclasses__() - [, , , , ] + >>> class A: pass + >>> class B(A): pass + >>> A.__subclasses__() + [] Class instances --------------- From 8d0b505fc72916599837a18b7d0d976c8921ff7a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 25 Sep 2024 23:04:57 -0700 Subject: [PATCH 2/2] fix --- Doc/reference/datamodel.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 6be4fe5ce1c5e3..5ce6bf17db41ea 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1112,7 +1112,7 @@ have the following two methods available: >>> class A: pass >>> class B(A): pass >>> A.__subclasses__() - [] + [] Class instances ---------------