Skip to content

Cannot return PyBytes / PyList? #1549

@vedantroy

Description

@vedantroy

I have the following:

    pub fn apply_local_change(&mut self, change: &PyAny) -> PyResult<(Py<PyAny>, PyBytes)> {
       // function implementation ...
        let bytes = *PyBytes::new(py, change.raw_bytes());
        Ok((pythonize(py, &patch)?, bytes))
    }

However, I get an error saying "the trait IntoPyCallbackOutput<_> is not implemented for Result<(pyo3::Py<PyAny>, PyBytes), PyErr>". Is there any reason this trait would not be implemented for PyBytes?

I can solve the problem by returning a Vec<u8>, but that seems less Pythonic.

Update: This seems to apply for all Py... types, i.e, I can't return a Pylist either.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions