Author: Matti Picus <matti.pi...@gmail.com>
Branch: issue2752
Changeset: r94283:882bbee00812
Date: 2018-04-09 10:32 +0300
http://bitbucket.org/pypy/pypy/changeset/882bbee00812/

Log:    after PyObject_GetBuffer fails, a second call also fails,
        PyString_AsString succeeds

diff --git a/pypy/module/cpyext/test/test_bufferobject.py 
b/pypy/module/cpyext/test/test_bufferobject.py
--- a/pypy/module/cpyext/test/test_bufferobject.py
+++ b/pypy/module/cpyext/test/test_bufferobject.py
@@ -81,14 +81,22 @@
                     return NULL;
                 
                 if (((unsigned char*)bp.buf)[0] != '0') {
+                    void * buf = (void*)bp.buf;
+                    unsigned char val[4];
+                    unsigned char * s = PyString_AsString(obj);
+                    memcpy(val, bp.buf, 4);
+                    PyBuffer_Release(&bp);
+                    if (PyObject_GetBuffer(obj, &bp, PyBUF_SIMPLE) == -1)
+                        return NULL;
                     PyErr_Format(PyExc_ValueError,
-                            "mismatch: 0x%x [%x %x %x %x...] instead of '0' 
(got len=%d)",
+                            "mismatch: %p [%x %x %x %x...] now %p [%x %x %x 
%x...] as str '%s'",
+                            buf, val[0], val[1], val[2], val[3],
+                            (void *)bp.buf,
                             ((unsigned char*)bp.buf)[0],
                             ((unsigned char*)bp.buf)[1],
                             ((unsigned char*)bp.buf)[2],
                             ((unsigned char*)bp.buf)[3],
-                            ((unsigned char*)bp.buf)[4],
-                            bp.len);
+                            s);
                     PyBuffer_Release(&bp);
                     return NULL;
                 }
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to