]> granicus.if.org Git - python/commitdiff
convertsimple(): call PyErr_NoMemory() on PyMem_NEW() failure
authorVictor Stinner <victor.stinner@haypocalc.com>
Sun, 6 Jun 2010 20:38:02 +0000 (20:38 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sun, 6 Jun 2010 20:38:02 +0000 (20:38 +0000)
Raise a more revelant error (MemoryError instead of TypeError)

Python/getargs.c

index 1806bf87ae78420de75729c0abe1949d957ee3f7..b4b5db283c69e3389ac4216b9a9ee6b7a4e94a0d 100644 (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);
             }