convertsimple(): call PyErr_NoMemory() on PyMem_NEW() failure

Raise a more revelant error (MemoryError instead of TypeError)
This commit is contained in:
Victor Stinner 2010-06-06 20:38:02 +00:00
parent 5cb6239f00
commit 2872e5b1f8
1 changed files with 2 additions and 0 deletions

View File

@ -1172,6 +1172,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
*buffer = PyMem_NEW(char, size + 1);
if (*buffer == NULL) {
Py_DECREF(s);
PyErr_NoMemory();
return converterr(
"(memory error)",
arg, msgbuf, bufsize);
@ -1215,6 +1216,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
*buffer = PyMem_NEW(char, size + 1);
if (*buffer == NULL) {
Py_DECREF(s);
PyErr_NoMemory();
return converterr("(memory error)",
arg, msgbuf, bufsize);
}