diff --git a/lib/id_tracker.cc b/lib/id_tracker.cc index c428e4f..490828d 100644 --- a/lib/id_tracker.cc +++ b/lib/id_tracker.cc @@ -302,7 +302,7 @@ void init_id_tracker(pybind11::module &m) py::arg("fname"), py::arg("relation_depth") = 0) .def("complete_backward_references", [](IdTracker &self, std::filesystem::path const &fname, int relation_depth) { - self.complete_backward_references(osmium::io::File{fname}, relation_depth); + self.complete_backward_references(osmium::io::File{fname.string()}, relation_depth); }, py::arg("fname"), py::arg("relation_depth") = 0) .def("complete_forward_references", &IdTracker::complete_forward_references, @@ -314,7 +314,7 @@ void init_id_tracker(pybind11::module &m) py::arg("fname"), py::arg("relation_depth") = 0) .def("complete_forward_references", [](IdTracker &self, std::filesystem::path const &fname, int relation_depth) { - self.complete_forward_references(osmium::io::File{fname.c_str()}, relation_depth); + self.complete_forward_references(osmium::io::File{fname.string()}, relation_depth); }, py::arg("fname"), py::arg("relation_depth") = 0) .def("id_filter", diff --git a/lib/io.cc b/lib/io.cc index 0eeff1a..5b4a545 100644 --- a/lib/io.cc +++ b/lib/io.cc @@ -31,10 +31,10 @@ PYBIND11_MODULE(io, m) .def(py::init()) .def(py::init()) .def(py::init<>([] (std::filesystem::path const &file) { - return new osmium::io::File(file.c_str()); + return new osmium::io::File(file.string()); })) .def(py::init<>([] (std::filesystem::path const &file, const char *format) { - return new osmium::io::File(file.c_str(), format); + return new osmium::io::File(file.string(), format); })) .def_property("has_multiple_object_versions", &osmium::io::File::has_multiple_object_versions, @@ -78,10 +78,10 @@ PYBIND11_MODULE(io, m) .def(py::init()) .def(py::init()) .def(py::init<>([] (std::filesystem::path const &file) { - return new osmium::io::Reader(file.c_str()); + return new osmium::io::Reader(file.string()); })) .def(py::init<>([] (std::filesystem::path const &file, osmium::osm_entity_bits::type etype) { - return new osmium::io::Reader(file.c_str(), etype); + return new osmium::io::Reader(file.string(), etype); })) .def(py::init(), py::keep_alive<1, 2>()) @@ -97,7 +97,7 @@ PYBIND11_MODULE(io, m) py::class_(m, "Writer") .def(py::init()) .def(py::init<>([] (std::filesystem::path const &file) { - return new osmium::io::Writer(file.c_str()); + return new osmium::io::Writer(file.string()); })) .def(py::init()) .def(py::init()) diff --git a/lib/osmium.cc b/lib/osmium.cc index 72cce25..1d7c0cf 100644 --- a/lib/osmium.cc +++ b/lib/osmium.cc @@ -106,14 +106,14 @@ PYBIND11_MODULE(_osmium, m) { py::arg("filename")); m.def("apply", [](std::filesystem::path const &fn, pyosmium::BaseHandler &h) { - osmium::io::Reader rd{fn}; + osmium::io::Reader rd{fn.string()}; pyosmium::apply(rd, h); }, py::arg("filename"), py::arg("handler")); m.def("apply", [](std::filesystem::path const &fn, py::args args) { pyosmium::HandlerChain handler{args}; - osmium::io::Reader rd{fn}; + osmium::io::Reader rd{fn.string()}; pyosmium::apply(rd, handler); }, py::arg("filename")); diff --git a/lib/simple_writer.cc b/lib/simple_writer.cc index 80b3d84..5126c77 100644 --- a/lib/simple_writer.cc +++ b/lib/simple_writer.cc @@ -358,7 +358,7 @@ void init_simple_writer(pybind11::module &m) py::arg("filetype") = "") .def(py::init<>([] (std::filesystem::path const &file, unsigned long bufsz, osmium::io::Header const *header, bool overwrite) { - return new SimpleWriter(file.c_str(), bufsz, header, overwrite, ""); + return new SimpleWriter(file.string().c_str(), bufsz, header, overwrite, ""); }), py::arg("filename"), py::arg("bufsz") = 4096*1024, py::arg("header") = nullptr, diff --git a/test/test_file_processor.py b/test/test_file_processor.py index 8d3a50e..c3d90ab 100644 --- a/test/test_file_processor.py +++ b/test/test_file_processor.py @@ -241,7 +241,7 @@ def test_filtered_handler_basehandler(opl_buffer, tmp_path): ids = IDCollector() - o.apply(str(testf), ids) + o.apply(testf, ids) assert ids.nodes == [3] assert ids.ways == [2]