Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Lib/test/test_positional_only_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def global_pos_only_and_normal(a, /, b):
def global_pos_only_defaults(a=1, /, b=2):
return a, b

def global_inner_has_pos_only():
def f(x: int, /): ...
return f


class PositionalOnlyTestCase(unittest.TestCase):

Expand Down Expand Up @@ -412,6 +416,9 @@ def method(self, /):

self.assertEqual(C().method(), sentinel)

def test_annotations(self):
assert global_inner_has_pos_only().__annotations__ == {'x': int}


if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix ``SystemError`` when nested function has annotation on positional-only
argument - by Anthony Sottile.
2 changes: 2 additions & 0 deletions Python/symtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,8 @@ static int
symtable_visit_annotations(struct symtable *st, stmt_ty s,
arguments_ty a, expr_ty returns)
{
if (a->posonlyargs && !symtable_visit_argannotations(st, a->posonlyargs))
return 0;
if (a->args && !symtable_visit_argannotations(st, a->args))
return 0;
if (a->vararg && a->vararg->annotation)
Expand Down