[New-bugs-announce] [issue23935] Clean up Clinic's type expressions of buffers

Larry Hastings report at bugs.python.org
Mon Apr 13 18:53:54 CEST 2015

New submission from Larry Hastings:

Clinic was previously pretty confused about what things accepted "bytes", "bytearray", "buffer", "robuffer", and "rwbuffer".  This is because the documentation itself was somewhat confusing.

The documentation was recently cleaned up on these in trunk (including one final fix from me this morning).  This patch cleans up Clinic's understanding of how the types map to the format units.

My notes on how the format units map to types is copy & pasted below.


the documentation for format units is a little confused, and it is therefore confusing


getbuffer (buffer)
y* s* z*
  uses PyObject_GetBuffer(arg, view, PyBUF_SIMPLE)
  requires PyBuffer_IsContiguous(view, 'C')
  doesn't check specifically for bytes objects
  handles bytes objects
  accepts bytesarray

convertbuffer (robuffer)
y y# s# z#
  handles "read-only buffer object",
  all it really does is ensure it doesn't have a pb_releasebuffer,
  then call getbuffer() above

  so it doesn't accept bytesarray, *just because*

doesn't accept bytes
s z es es#

requires writeable buffer (rwbuffer)

actually checks / specifically handles bytes objects

actually checks / specifically handles bytearray objects

actually checks / specifically handles bytes and bytearray objects
c et et#

assignee: larry
components: Argument Clinic
messages: 240660
nosy: larry, serhiy.storchaka, zach.ware
priority: normal
severity: normal
stage: patch review
status: open
title: Clean up Clinic's type expressions of buffers
type: behavior
versions: Python 3.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list