Skip to content

py::isinstance<py::str>(py_bytes_object) should not return true #1461

Closed
@jbarlow83

Description

@jbarlow83

Issue description

In pybind 2.2.3, the template specialization py::isinstance<py::str>() returns True when used on py::bytes objects. This is incorrect in both Py2 and 3 (since py::str is unicode in Py2).

py::instance(obj, py::str().get_type()) works correctly.

Reproducible example code

    m.def("test_isinstance",
        []() {
            py::bytes b = "123";
            py::print(py::isinstance<py::str>(b));
        }
    );
>>> pybind11.test_isinstance()
True

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions