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
3 changes: 3 additions & 0 deletions Lib/test/test_type_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@ def test_non_utf8_type_comment_with_ignore_cookie(self):
with self.assertRaises(UnicodeDecodeError):
_testcapi.Py_CompileStringExFlags(
b"a=1 # type: \x80", "<test>", 256, flags)
with self.assertRaises(UnicodeDecodeError):
_testcapi.Py_CompileStringExFlags(
b"def a(f=8, #type: \x80\n\x80", "<test>", 256, flags)

def test_func_type_input(self):

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix an unlikely crash when parsing an invalid type comments for function
parameters. Found by OSS Fuzz in :oss-fuzz:`492782951`.
3 changes: 3 additions & 0 deletions Parser/action_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,9 @@ _PyPegen_name_default_pair(Parser *p, arg_ty arg, expr_ty value, Token *tc)
return NULL;
}
a->arg = _PyPegen_add_type_comment_to_arg(p, arg, tc);
if (!a->arg) {
return NULL;
}
a->value = value;
return a;
}
Expand Down
Loading