[New-bugs-announce] [issue46236] PyFunction_GetAnnotations returning Tuple vs Dict
report at bugs.python.org
Sun Jan 2 22:16:05 EST 2022
New submission from Daniel McCarney <daniel at binaryparadox.net>:
This is my first Python bug, hope I haven't missed anything important.
I noticed that the PyFunction_GetAnnotations function from the C API is returning a PyTuple when I link Python 3.10 where historically it returned a PyDict.
The documentation for PyFunction_GetAnnotations for 3.10 (here) says its return can be:
> a mutable dictionary or NULL
I'm not sure if:
* This is user error and I should adapt to this case in my dependent code when using Python 3.10+.
* This is a documentation error, and it should say "a mutable dictionary, set, or NULL"
* This is a regression in the C API that should be fixed.
I've made a small reproduction program (here) that can be used to quickly demonstrate the difference in return type between the two Python versions for the same C program and .py inputs.
I also noticed that issue42202 (here) landed an optimization in 3.10.x that changed the internal representation of annotations to a set - could that possibly be related? I'm not 100% sure!
components: C API
title: PyFunction_GetAnnotations returning Tuple vs Dict
versions: Python 3.10
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce