Commits

Jean-Paul Calderone committed 32677db

Correct the reference counting in this Py_buffer/PyArg_ParseTuple test

Comments (0)

Files changed (1)

pypy/module/cpyext/test/test_getargs.py

         pybuffer = self.import_parser(
             '''
             Py_buffer buf;
+            PyObject *result;
             if (!PyArg_ParseTuple(args, "s*", &buf)) {
                 return NULL;
             }
-            return PyString_FromStringAndSize(buf.buf, buf.len);
+            result = PyString_FromStringAndSize(buf.buf, buf.len);
+            PyBuffer_Release(&buf);
+            return result;
             ''')
         assert 'foo\0bar\0baz' == pybuffer('foo\0bar\0baz')