Closed
Description
In issue #30409 PyFunction_GetAnnotations
was fixed so it wouldn't return a tuple. That's good.
But this change changed the return value. PyFunction_GetAnnotations
now returns a new reference to the annotations dict. But according to the documentation, it should return a borrowed reference.
https://docs.python.org/3/c-api/function.html#c.PyFunction_GetAnnotations
If users only read the documentation, and assume that it's correct, they'll leak a reference to the annotation dict.
We could fix this by changing the documentation. However, all the other PyFunction_Get*
functions also return borrowed references. So I think the correct fix is to remove the incref.