Skip to content

Check documentation of PyObject_CopyData #102383

Description

@purpleKarrot

According to the documentation, PyObject_CopyData takes two arguments of type Py_buffer*:

.. c:function:: int PyObject_CopyData(Py_buffer *dest, Py_buffer *src)

But in the implementation, it actually takes two arguments of PyObject*:

int PyObject_CopyData(PyObject *dest, PyObject *src)

Linked PRs

Activity

  1. terryjreedy commented on Mar 3, 2023

    @terryjreedy
    Member

    I few lines below, abstract.c has

        if (!PyObject_CheckBuffer(dest) ||
            !PyObject_CheckBuffer(src)) {
            PyErr_SetString(PyExc_TypeError,
                            "both destination and source must be "\
                            "bytes-like objects");
    

    So the 'PyObjects' indeed have to be buffer-like. I don't know the technical details, but I suspect that there is no real bug.

  2. ronaldoussoren commented on Mar 3, 2023

    @ronaldoussoren
    Contributor

    I don't know the technical details, but I suspect that there is no real bug.

    There is a bug as the documentation does not match the implementation, Py_buffer is not a Python object. In this case IMHO the documentation should be fixed.

  3. sobolevn commented on Mar 3, 2023

    @sobolevn
    Member

    Yes, PyObject_CheckBuffer looks like so:

    int
    PyObject_CheckBuffer(PyObject *obj)
    {
        PyBufferProcs *tp_as_buffer = Py_TYPE(obj)->tp_as_buffer;
        return (tp_as_buffer != NULL && tp_as_buffer->bf_getbuffer != NULL);
    }

    So, there's clearly a bug in the docs. PR is sent :)
    Thanks a lot for the report!

  4. added a commit that references this issue on Mar 3, 2023
  5. added
    type-bugAn unexpected behavior, bug, or error
    docsDocumentation in the Doc dir
    on Mar 3, 2023
  6. added a commit that references this issue on Mar 3, 2023
  7. added 2 commits that reference this issue on Mar 3, 2023
  8. added a commit that references this issue on Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions