diff --git a/Bindings/Python/swig/python_preliminaries.i b/Bindings/Python/swig/python_preliminaries.i index 91f636944c..13c9a31f72 100644 --- a/Bindings/Python/swig/python_preliminaries.i +++ b/Bindings/Python/swig/python_preliminaries.i @@ -48,3 +48,22 @@ note: ## is a "glue" operator: `a ## b` --> `ab`. %} }; %enddef + +// Support for pathlib.Path objects +// ================================ +%typemap(in) std::string const & (std::string temp, int res = SWIG_OLDOBJ) { + if (PyUnicode_Check($input)) { + temp = std::string(PyUnicode_AsUTF8($input)); + $1 = &temp; + } else { + PyObject* fspath = PyOS_FSPath($input); + if (fspath != NULL) { + temp = std::string(PyUnicode_AsUTF8(fspath)); + Py_DECREF(fspath); + $1 = &temp; + } else { + PyErr_Clear(); + %argument_fail(SWIG_TypeError, "std::string const &", $symname, $argnum); + } + } +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 95b3007a87..39bc7fe01f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,9 +35,9 @@ performance and stability in wrapping solutions. - Implemented `generateDecorations()` for `Station` to allow visualization in the Simbody visualizer. (#4169) - Added `Component::removeComponent` and `Component::extractComponent` methods, which enable removing subcomponents that were previously added via `Component::addComponent` or the `` XML element (#4174). - Updated required language level to C++20. (#3929) +- Python API accepts Path objects instead of only strings - Breaking: removed the `operator==` and `operator<` overloads in `ControlLinearNode` and replaced usages with the equivalent utility functions `isEqual()` and `isLessThan()`. (#4095) - v4.5.2 ====== - The performance of `getStateVariableValue`, `getStateVariableDerivativeValue`, and `getModelingOption` was improved in