Commits

Lenard Lindstrom committed 147a027

Allow read-only requests on a Surface return BufferProxy object

BufferProxy objects returned by Surface.get_buffer(t) calls would reject a
PyBUF_RECORDS_RO flag when 't' was one of '2', '3', 'r', 'g', 'b', or 'a'.
This was unnecessary. It conflicts with adding new buffer support to the
pixelcopy module functions, since source arrays can be read-only.

  • Participants
  • Parent commits 440c63e

Comments (0)

Files changed (1)

File src/surface.c

     char *format;
 
     view_p->obj = 0;
-    if ((flags & PyBUF_RECORDS) != PyBUF_RECORDS) {
+    if ((flags & PyBUF_RECORDS_RO) != PyBUF_RECORDS_RO) {
         PyErr_SetString (PgExc_BufferError,
-                         "A PyBUF_RECORDS flag is required for a "
+                         "A PyBUF_RECORDS(_RO) flag is required for a "
                          "2D surface view");
         return -1;
     }
     char *startpixel = (char *)surface->pixels;
 
     view_p->obj = 0;
-    if ((flags & PyBUF_RECORDS) != PyBUF_RECORDS) {
+    if ((flags & PyBUF_RECORDS_RO) != PyBUF_RECORDS_RO) {
         PyErr_SetString (PgExc_BufferError,
-                         "A PyBUF_RECORDS flag is required for a "
+                         "A PyBUF_RECORDS(_RO) flag is required for a "
                          "2D surface view");
         return -1;
     }
     char *startpixel = (char *)surface->pixels;
 
     view_p->obj = 0;
-    if ((flags & PyBUF_RECORDS) != PyBUF_RECORDS) {
+    if ((flags & PyBUF_RECORDS_RO) != PyBUF_RECORDS_RO) {
         PyErr_SetString (PgExc_BufferError,
-                         "A PyBUF_RECORDS flag is required for a "
+                         "A PyBUF_RECORDS(_RO) flag is required for a "
                          "surface colorplane view");
         return -1;
     }