Issue #18408: Fix compiler_import() to handle PyUnicode_Substring() failure properly

This commit is contained in:
Victor Stinner 2013-07-11 22:50:45 +02:00
parent 9a4fb66966
commit 6b64a6803e
1 changed files with 4 additions and 1 deletions

View File

@ -2316,8 +2316,11 @@ compiler_import(struct compiler *c, stmt_ty s)
identifier tmp = alias->name;
Py_ssize_t dot = PyUnicode_FindChar(
alias->name, '.', 0, PyUnicode_GET_LENGTH(alias->name), 1);
if (dot != -1)
if (dot != -1) {
tmp = PyUnicode_Substring(alias->name, 0, dot);
if (tmp == NULL)
return 0;
}
r = compiler_nameop(c, tmp, Store);
if (dot != -1) {
Py_DECREF(tmp);