mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #18408: Fix compiler_import() to handle PyUnicode_Substring() failure properly
This commit is contained in:
parent
9a4fb66966
commit
6b64a6803e
1 changed files with 4 additions and 1 deletions
|
@ -2316,8 +2316,11 @@ compiler_import(struct compiler *c, stmt_ty s)
|
||||||
identifier tmp = alias->name;
|
identifier tmp = alias->name;
|
||||||
Py_ssize_t dot = PyUnicode_FindChar(
|
Py_ssize_t dot = PyUnicode_FindChar(
|
||||||
alias->name, '.', 0, PyUnicode_GET_LENGTH(alias->name), 1);
|
alias->name, '.', 0, PyUnicode_GET_LENGTH(alias->name), 1);
|
||||||
if (dot != -1)
|
if (dot != -1) {
|
||||||
tmp = PyUnicode_Substring(alias->name, 0, dot);
|
tmp = PyUnicode_Substring(alias->name, 0, dot);
|
||||||
|
if (tmp == NULL)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
r = compiler_nameop(c, tmp, Store);
|
r = compiler_nameop(c, tmp, Store);
|
||||||
if (dot != -1) {
|
if (dot != -1) {
|
||||||
Py_DECREF(tmp);
|
Py_DECREF(tmp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue