]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-123242: Note that type.__annotations__ may not exist (#124557)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Wed, 25 Sep 2024 23:08:14 +0000 (16:08 -0700)
committerGitHub <noreply@github.com>
Wed, 25 Sep 2024 23:08:14 +0000 (16:08 -0700)
Closes #123242. The real criterion is that the attribute does not
exist on heap types, but I don't think we should discuss heap vs.
static types in the language reference.

Doc/reference/datamodel.rst

index 7a93a9f770b474cedbf4301c01a634b6d3c4cf69..a6348eda3891cc4c3f07ac44b4e2d88de5f2505d 100644 (file)
@@ -1045,7 +1045,8 @@ Special attributes
 
           Accessing the :attr:`!__annotations__` attribute of a class
           object directly may yield incorrect results in the presence of
-          metaclasses. Use :func:`annotationlib.get_annotations` to
+          metaclasses. In addition, the attribute may not exist for
+          some classes. Use :func:`annotationlib.get_annotations` to
           retrieve class annotations safely.
 
        .. versionchanged:: 3.14