mirror of
https://github.com/python/cpython.git
synced 2026-04-20 10:51:00 +00:00
gh-143886: Ensure function annotations are returned in order of definition (#143888)
Ensure function annotations are returned in order of definition Previously, when getting type annotations of a function, normal arguments were returned before positional-only ones in the dictionary. Since `functools.singledispatch` relies on this ordering being correct to dispatch based on the type of the first argument, this issue was causing incorrect registrations for functions with positional-only arguments. This commit updates how annotations are generated so that positional-only arguments are generated and added to the dictionary before normal arguments.
This commit is contained in:
parent
ab45919812
commit
cb339d3c9e
4 changed files with 27 additions and 2 deletions
|
|
@ -1130,10 +1130,10 @@ codegen_annotations_in_scope(compiler *c, location loc,
|
|||
Py_ssize_t *annotations_len)
|
||||
{
|
||||
RETURN_IF_ERROR(
|
||||
codegen_argannotations(c, args->args, annotations_len, loc));
|
||||
codegen_argannotations(c, args->posonlyargs, annotations_len, loc));
|
||||
|
||||
RETURN_IF_ERROR(
|
||||
codegen_argannotations(c, args->posonlyargs, annotations_len, loc));
|
||||
codegen_argannotations(c, args->args, annotations_len, loc));
|
||||
|
||||
if (args->vararg && args->vararg->annotation) {
|
||||
RETURN_IF_ERROR(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue