Skip to content

Relax "bytes" requirement when reading #572

@smurfix

Description

@smurfix

The unpacker currently requires the file to return bytes.

cdef read_from_file(self):
        next_bytes = self.file_like_read(
                min(self.read_size,
                    self.max_buffer_size - (self.buf_tail - self.buf_head)
                    ))
        if next_bytes:
            self.append_buffer(PyBytes_AsString(next_bytes), PyBytes_Size(next_bytes))
        else:
            self.file_like = None

Is it possible to relax this?

The returned object must of course support the buffer protocol, but beyond that it shouldn't be required to be a bytes type. It could be a memoryview into an in-memory "file". There should be no requirement to copy the data; the unpacker does that anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions