Skip to content

Argument Clinic: the Py_buffer converter only accepts None as the default value #144545

Description

@serhiy-storchaka

Bug report

The Py_buffer converter only accepts None as the default value, even if None is not valid value for Py_buffer. As result, you need to use tricks for optional Py_buffer parameters:

Py_buffer(py_default="b''") = None

or

Py_buffer(py_default="<unrepresentable>") = None

and then check if arg->buf is NULL.

It should support NULL (for "unrepresentable") and arbitrary bytes literals (or at least b'') as default values.

Linked PRs

Activity

  1. added 4 commits that reference this issue on Mar 16, 2026
  2. added a commit that references this issue on Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions