Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b64a68

Browse files
committed
Issue #18408: Fix compiler_import() to handle PyUnicode_Substring() failure properly
1 parent 9a4fb66 commit 6b64a68

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Python/compile.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2316,8 +2316,11 @@ compiler_import(struct compiler *c, stmt_ty s)
23162316
identifier tmp = alias->name;
23172317
Py_ssize_t dot = PyUnicode_FindChar(
23182318
alias->name, '.', 0, PyUnicode_GET_LENGTH(alias->name), 1);
2319-
if (dot != -1)
2319+
if (dot != -1) {
23202320
tmp = PyUnicode_Substring(alias->name, 0, dot);
2321+
if (tmp == NULL)
2322+
return 0;
2323+
}
23212324
r = compiler_nameop(c, tmp, Store);
23222325
if (dot != -1) {
23232326
Py_DECREF(tmp);

0 commit comments

Comments
 (0)