TD: Wrap PyArg_ParseTupleAndKeywords

This commit is contained in:
Chris Hennes
2023-08-25 13:19:09 -05:00
parent 079617a58e
commit c60944ed62
3 changed files with 15 additions and 9 deletions

View File

@@ -27,6 +27,8 @@
# include <boost/uuid/uuid_io.hpp>
#endif
#include <Base/PyWrapParseTupleAndKeywords.h>
#include "CosmeticEdgePy.h"
#include "CosmeticEdgePy.cpp"
#include "Cosmetic.h"
@@ -122,9 +124,9 @@ void CosmeticEdgePy::setFormat(Py::Dict arg)
double weight = 0.5;
PyObject* pColor = color.ptr();
PyObject* visible = Py_True;
static char* kw[] = {"style", "weight", "color", "visible", nullptr};
if (!PyArg_ParseTupleAndKeywords(dummy.ptr(), arg.ptr(), "|idO!O!", kw,
&style, &weight, &PyTuple_Type, &pColor, &PyBool_Type, &visible)) {
static const std::array<const char *, 5> kw{"style", "weight", "color", "visible", nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(dummy.ptr(), arg.ptr(), "|idO!O!", kw,
&style, &weight, &PyTuple_Type, &pColor, &PyBool_Type, &visible)) {
throw Py::ValueError("Expected {'style':int, 'weight':float, 'color':tuple, 'visible':bool} dict");
}