]> granicus.if.org Git - python/commitdiff
Issue #22896: Fixed using _getbuffer() in recently added _PyBytes_Format().
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 2 Feb 2015 23:49:18 +0000 (01:49 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 2 Feb 2015 23:49:18 +0000 (01:49 +0200)
Objects/bytesobject.c

index b2fbc926228d8de4c90fa835634620f3f4e2d1ec..b2bf09840935c073bb798889091634626e56a642 100644 (file)
@@ -622,14 +622,13 @@ _PyBytes_Format(PyObject *format, PyObject *args)
             int isnumok;
             PyObject *v = NULL;
             PyObject *temp = NULL;
-            Py_buffer buf;
+            Py_buffer buf = {NULL, NULL};
             char *pbuf;
             int sign;
             Py_ssize_t len;
             char formatbuf[FORMATBUFLEN];
                  /* For format{int,char}() */
 
-            buf.obj = NULL;
             fmt++;
             if (*fmt == '(') {
                 char *keystart;
@@ -790,7 +789,7 @@ _PyBytes_Format(PyObject *format, PyObject *args)
                     Py_DECREF(temp);
                     goto error;
                 }
-                if (_getbuffer(repr, &buf) < 0) {
+                if (PyObject_GetBuffer(repr, &buf, PyBUF_SIMPLE) != 0) {
                     temp = format_obj(repr);
                     if (temp == NULL) {
                         Py_DECREF(repr);