mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
Issue #27352: Correct the validation of the ImportFrom AST node and simplify
the implementation of the IMPORT_NAME opcode.
This commit is contained in:
parent
44a98b6bf3
commit
fbd1523525
2 changed files with 3 additions and 11 deletions
|
@ -475,8 +475,8 @@ validate_stmt(stmt_ty stmt)
|
|||
case Import_kind:
|
||||
return validate_nonempty_seq(stmt->v.Import.names, "names", "Import");
|
||||
case ImportFrom_kind:
|
||||
if (stmt->v.ImportFrom.level < -1) {
|
||||
PyErr_SetString(PyExc_ValueError, "ImportFrom level less than -1");
|
||||
if (stmt->v.ImportFrom.level < 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "Negative ImportFrom level");
|
||||
return 0;
|
||||
}
|
||||
return validate_nonempty_seq(stmt->v.ImportFrom.names, "names", "ImportFrom");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue