mirror of
https://github.com/python/cpython.git
synced 2026-07-06 01:39:24 -04:00
[3.13] gh-148157: Check for _PyPegen_add_type_comment_to_arg fail in _PyPegen_name_default_pair (GH-148158) (#148163)
(cherry picked from commit 1795fccfbc)
Co-authored-by: Stan Ulbrych <stan@python.org>
This commit is contained in:
committed by
GitHub
parent
9b576f14bf
commit
4dfcdbe22c
@@ -398,6 +398,9 @@ class TypeCommentTests(unittest.TestCase):
|
||||
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):
|
||||
|
||||
|
||||
@@ -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`.
|
||||
@@ -434,6 +434,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user