Loading src/Load.cpp +16 −7 Original line number Diff line number Diff line Loading @@ -85,6 +85,7 @@ namespace ale { "Check if Installed correctly and the function ale.loads exists."); } // Create a Python tuple to hold the arguments to the method. PyObject *pArgs = PyTuple_New(3); if(!pArgs) { Loading @@ -94,16 +95,19 @@ namespace ale { // Set the Python int as the first and second arguments to the method. PyObject *pStringFileName = PyUnicode_FromString(filename.c_str()); PyTuple_SetItem(pArgs, 0, pStringFileName); Py_INCREF(pStringFileName); // take ownership of reference PyObject *pStringProps = PyUnicode_FromString(props.c_str()); PyTuple_SetItem(pArgs, 1, pStringProps); Py_INCREF(pStringProps); // take ownership of reference PyObject *pStringFormatter = PyUnicode_FromString(formatter.c_str()); PyTuple_SetItem(pArgs, 2, pStringFormatter); Py_INCREF(pStringFormatter); // take ownership of reference // Call the function with the arguments. PyObject* pResult = PyObject_CallObject(pFunc, pArgs); if(!pResult) { throw invalid_argument("No Valid instrument found for label."); } Loading @@ -114,15 +118,20 @@ namespace ale { if(!temp_bytes){ throw invalid_argument(getPyTraceback()); } std::string cResult; char *temp_str = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer cResult = temp_str; // copy into std::string Py_DECREF(pResultStr); Py_DECREF(pStringFileName); Py_DECREF(pStringProps); Py_DECREF(pStringFormatter); Py_DECREF(pArgs); return cResult; } Loading Loading
src/Load.cpp +16 −7 Original line number Diff line number Diff line Loading @@ -85,6 +85,7 @@ namespace ale { "Check if Installed correctly and the function ale.loads exists."); } // Create a Python tuple to hold the arguments to the method. PyObject *pArgs = PyTuple_New(3); if(!pArgs) { Loading @@ -94,16 +95,19 @@ namespace ale { // Set the Python int as the first and second arguments to the method. PyObject *pStringFileName = PyUnicode_FromString(filename.c_str()); PyTuple_SetItem(pArgs, 0, pStringFileName); Py_INCREF(pStringFileName); // take ownership of reference PyObject *pStringProps = PyUnicode_FromString(props.c_str()); PyTuple_SetItem(pArgs, 1, pStringProps); Py_INCREF(pStringProps); // take ownership of reference PyObject *pStringFormatter = PyUnicode_FromString(formatter.c_str()); PyTuple_SetItem(pArgs, 2, pStringFormatter); Py_INCREF(pStringFormatter); // take ownership of reference // Call the function with the arguments. PyObject* pResult = PyObject_CallObject(pFunc, pArgs); if(!pResult) { throw invalid_argument("No Valid instrument found for label."); } Loading @@ -114,15 +118,20 @@ namespace ale { if(!temp_bytes){ throw invalid_argument(getPyTraceback()); } std::string cResult; char *temp_str = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer cResult = temp_str; // copy into std::string Py_DECREF(pResultStr); Py_DECREF(pStringFileName); Py_DECREF(pStringProps); Py_DECREF(pStringFormatter); Py_DECREF(pArgs); return cResult; } Loading