mirror of
https://github.com/pybind/pybind11.git
synced 2026-06-07 08:15:22 +00:00
Add check if str(handle) correctly converted the object, and throw py::error_already_set if not (bis) (#2477)
* Add check if `str(handle)` correctly converted the object, and throw py::error_already_set if not * Fix tests on Python 3 * Apply @rwgk's fixes to cherry-picked commits from #2392
This commit is contained in:
@@ -80,6 +80,7 @@ TEST_SUBMODULE(pytypes, m) {
|
||||
m.def("str_from_bytes", []() { return py::str(py::bytes("boo", 3)); });
|
||||
m.def("str_from_object", [](const py::object& obj) { return py::str(obj); });
|
||||
m.def("repr_from_object", [](const py::object& obj) { return py::repr(obj); });
|
||||
m.def("str_from_handle", [](py::handle h) { return py::str(h); });
|
||||
|
||||
m.def("str_format", []() {
|
||||
auto s1 = "{} + {} = {}"_s.format(1, 2, 3);
|
||||
|
||||
Reference in New Issue
Block a user