This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gvanrossum
Recipients Guido.van.Rossum, eric.smith, gvanrossum, larry
Date 2021-04-24.23:08:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Functions don't store __annotations__ in their __dict__, it is a separate slot named func_annotations (see funcobject.c). I guess that's because the __dict__ is purely for user-defined function attributes.

But perhaps for classes the C equivalent of this pseudo-code will work?

def __annotations__(self):
    if "__annotations__" not in self.__dict__:
        self.__dict__["__annotations__"] = {}
    return self.__dict__["__annotations__"]

The whole thing is protected by the GIL of course, so there's no race condition between the check and the assignment.

So if you look in __dict__ it will be like it's still Python 3.9, but if you're using the attribute (the recommended approach for code that only cares about 3.10) it'll be as if it always existed. Sounds pretty compatible to me.
Date User Action Args
2021-04-24 23:08:59gvanrossumsetrecipients: + gvanrossum, larry, eric.smith, Guido.van.Rossum
2021-04-24 23:08:59gvanrossumsetmessageid: <>
2021-04-24 23:08:59gvanrossumlinkissue43901 messages
2021-04-24 23:08:58gvanrossumcreate