Built-in Exceptions

BufferError — exception class

Indicates an invalid operation involving an exported buffer. For example, a bytearray cannot grow while a memoryview exports its storage. Release the view before resizing; equal-length writes may remain possible. Catch BufferError when this category is the recovery boundary; do not rely on the exact human-readable message.

Formal Syntax & Structure

python syntaxpython
BufferError

Return Value

type

The class object BufferError; this reference documents the class identity, not a universal constructor signature.

Working Example

Example Snippetpython
data=bytearray(b"B")try:    with memoryview(data):        data.append(65)except BufferError as error:    print(type(error).__name__)
Python Reference