mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
SF patch 1025636: Check for NULL returns in compile.c:com_import_stmt
There is no test for this change, because there is no way to provoke memory errors on demand. Test suite passes, though.
This commit is contained in:
parent
84a6c205e3
commit
16b047904c
1 changed files with 14 additions and 4 deletions
|
@ -3606,10 +3606,20 @@ com_import_stmt(struct compiling *c, node *n)
|
||||||
}
|
}
|
||||||
REQ(nn, import_as_names);
|
REQ(nn, import_as_names);
|
||||||
tup = PyTuple_New((NCH(nn) + 1) / 2);
|
tup = PyTuple_New((NCH(nn) + 1) / 2);
|
||||||
for (i = 0; i < NCH(nn); i += 2)
|
for (i = 0; i < NCH(nn); i += 2) {
|
||||||
PyTuple_SET_ITEM(tup, i / 2,
|
PyObject *s = PyString_FromString(
|
||||||
PyString_FromString(STR(
|
STR(CHILD(CHILD(nn, i), 0)));
|
||||||
CHILD(CHILD(nn, i), 0))));
|
if (s == NULL) {
|
||||||
|
Py_CLEAR(tup);
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
PyTuple_SET_ITEM(tup, i / 2, s);
|
||||||
|
}
|
||||||
|
if (tup == NULL) {
|
||||||
|
/* Assume that failue above was MemoryError */
|
||||||
|
com_error(c, PyExc_MemoryError, "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
com_addoparg(c, LOAD_CONST, com_addconst(c, tup));
|
com_addoparg(c, LOAD_CONST, com_addconst(c, tup));
|
||||||
Py_DECREF(tup);
|
Py_DECREF(tup);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue