Overview

Module newbuffer

What is it?

A module which exports the Python mixin BufferMixin. The mixin adds a new buffer interface to a Python new-style class. The primary use is in Pygame unit tests to verify the new buffer protocol support added in Version 1.9.2.

How it works

The newbuffer module exports BufferMixin, an extension class exporting the new buffer interface. Its bf_getbuffer and bf_releasebuffer slot functions in turn call Python level methods _get_buffer(self, view, flags) and _release_buffer(self, view) respectively.

The view argument is an object that gives access to a Py_buffer C struct fields through object properties. The lifetime of a view object's data is limited to a bf_getbuffer or bf_releasebuffer call. Elsewhere, a Py_buffer field property access on the object raises a Python exception.

TODO

  • Allow a BufferMixin._get_buffer method to pass on the bf_getbuffer call to another object.