sources=sources,
extra_compile_args=args)
-setup(name="pyffish", version="0.0.52",
+setup(name="pyffish", version="0.0.53",
description="Fairy-Stockfish Python wrapper",
long_description=long_description,
long_description_content_type="text/markdown",
int numMoves = PyList_Size(moveList);
for (int i = 0; i < numMoves ; i++)
{
- std::string moveStr(PyBytes_AS_STRING(PyUnicode_AsEncodedString( PyList_GetItem(moveList, i), "UTF-8", "strict")));
+ PyObject *MoveStr = PyUnicode_AsEncodedString( PyList_GetItem(moveList, i), "UTF-8", "strict");
+ std::string moveStr(PyBytes_AS_STRING(MoveStr));
+ Py_XDECREF(MoveStr);
Move m;
if ((m = UCI::to_move(pos, moveStr)) != MOVE_NONE)
{
if (!PyArg_ParseTuple(args, "sO", &name, &valueObj)) return NULL;
if (Options.count(name))
- Options[name] = std::string(PyBytes_AS_STRING(PyUnicode_AsEncodedString(PyObject_Str(valueObj), "UTF-8", "strict")));
+ {
+ PyObject *Value = PyUnicode_AsEncodedString( PyObject_Str(valueObj), "UTF-8", "strict");
+ Options[name] = std::string(PyBytes_AS_STRING(Value));
+ Py_XDECREF(Value);
+ }
else
{
PyErr_SetString(PyExc_ValueError, (std::string("No such option ") + name + "'").c_str());
StateListPtr states(new std::deque<StateInfo>(1));
buildPosition(pos, states, variant, fen, moveList, chess960);
std::string moveStr = move;
+
+ Py_XDECREF(moveList);
return Py_BuildValue("s", move_to_san(pos, UCI::to_move(pos, moveStr), notation).c_str());
}
int numMoves = PyList_Size(moveList);
for (int i=0; i<numMoves ; i++) {
- std::string moveStr(PyBytes_AS_STRING(PyUnicode_AsEncodedString( PyList_GetItem(moveList, i), "UTF-8", "strict")));
+ PyObject *MoveStr = PyUnicode_AsEncodedString( PyList_GetItem(moveList, i), "UTF-8", "strict");
+ std::string moveStr(PyBytes_AS_STRING(MoveStr));
+ Py_XDECREF(MoveStr);
Move m;
if ((m = UCI::to_move(pos, moveStr)) != MOVE_NONE)
{
return NULL;
}
}
- return sanMoves;
+ PyObject *Result = Py_BuildValue("O", sanMoves);
+ Py_XDECREF(sanMoves);
+ return Result;
}
// INPUT variant, fen, move list
PyList_Append(legalMoves, moveStr);
Py_XDECREF(moveStr);
}
- return legalMoves;
+
+ PyObject *Result = Py_BuildValue("O", legalMoves);
+ Py_XDECREF(legalMoves);
+ return Result;
}
// INPUT variant, fen, move list