]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-101100: Make __subclasses__ doctest stable (GH-124577) (#124579)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 26 Sep 2024 20:56:06 +0000 (22:56 +0200)
committerGitHub <noreply@github.com>
Thu, 26 Sep 2024 20:56:06 +0000 (13:56 -0700)
gh-101100: Make __subclasses__ doctest stable (GH-124577)

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.
(cherry picked from commit 08a467b537b3d9b499d060697e79b3950374ab0f)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Doc/reference/datamodel.rst

index dfc7e8ef056a501011799e911df7c7304b044681..45c4852da03f446f86136b82398b40fab5f56f2b 100644 (file)
@@ -1053,8 +1053,10 @@ have the following two methods available:
 
    .. doctest::
 
-      >>> int.__subclasses__()
-      [<class 'bool'>, <enum 'IntEnum'>, <flag 'IntFlag'>, <class 're._constants._NamedIntConstant'>, <class 're._ZeroSentinel'>]
+      >>> class A: pass
+      >>> class B(A): pass
+      >>> A.__subclasses__()
+      [<class 'B'>]
 
 Class instances
 ---------------