Skip to content

Add const qualifier to format member of Py_buffer #155819

Description

@hpkfft

Feature or enhancement

Proposal:

CPython often sets the char *format member of a Py_buffer to a string literal such as "B". If an extension using the C API were to attempt to modify the string, the behavior would be undefined.
It is generally considered good practice to advertise that the string pointed to by format should not be mutated by giving it type const char *.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/can-py-buffer-format-be-const-qualified/108522

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions