File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919 * If not, see <http://www.gnu.org/licenses/>.
2020 */
2121#include " openPMD/Series.hpp"
22+ #include " openPMD/Error.hpp"
2223#include " openPMD/IO/Access.hpp"
2324#include " openPMD/Iteration.hpp"
2425#include " openPMD/IterationEncoding.hpp"
@@ -104,6 +105,14 @@ struct DefineSeriesConstructorPerPathType
104105 static auto filepath_as_string (py::object const &path) -> std::string
105106 {
106107 auto casted = path.attr (" __str__" )();
108+ auto type_repr = py::repr (path).cast <std::string>();
109+ if (type_repr.substr (0 , 9 ) != " PosixPath" &&
110+ type_repr.substr (0 , 11 ) != " WindowsPath" )
111+ {
112+ throw error::WrongAPIUsage (
113+ " openpmd.Series constructor: 'filepath' argument may either be "
114+ " a String or pathlib.Path." );
115+ }
107116 return py::cast<std::string>(casted);
108117 }
109118#endif
You can’t perform that action at this time.
0 commit comments