mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-43892: Validate the first term of complex literal value patterns (GH-25735)
This commit is contained in:
parent
87655e2cf5
commit
dbe60ee09d
8 changed files with 595 additions and 441 deletions
|
@ -2352,7 +2352,17 @@ expr_ty
|
|||
_PyPegen_ensure_imaginary(Parser *p, expr_ty exp)
|
||||
{
|
||||
if (exp->kind != Constant_kind || !PyComplex_CheckExact(exp->v.Constant.value)) {
|
||||
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(exp, "Imaginary number required in complex literal");
|
||||
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(exp, "imaginary number required in complex literal");
|
||||
return NULL;
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
expr_ty
|
||||
_PyPegen_ensure_real(Parser *p, expr_ty exp)
|
||||
{
|
||||
if (exp->kind != Constant_kind || PyComplex_CheckExact(exp->v.Constant.value)) {
|
||||
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(exp, "real number required in complex literal");
|
||||
return NULL;
|
||||
}
|
||||
return exp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue