From 645122f4b365ce44849afda2ed8a711ae649ed76 Mon Sep 17 00:00:00 2001 From: "Daniel M. Pelt" Date: Tue, 21 Jul 2015 13:56:18 +0200 Subject: Fix 'get_registered' in Matlab with Python 3 --- src/PluginAlgorithm.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/PluginAlgorithm.cpp') diff --git a/src/PluginAlgorithm.cpp b/src/PluginAlgorithm.cpp index 5c779fd..5d6d733 100644 --- a/src/PluginAlgorithm.cpp +++ b/src/PluginAlgorithm.cpp @@ -249,11 +249,24 @@ std::map CPluginAlgorithmFactory::getRegisteredMap(){ PyObject *key, *value; Py_ssize_t pos = 0; while (PyDict_Next(pluginDict, &pos, &key, &value)) { - PyObject * keyb = PyObject_Bytes(key); - PyObject * valb = PyObject_Bytes(value); - ret[PyBytes_AsString(keyb)] = PyBytes_AsString(valb); - Py_DECREF(keyb); - Py_DECREF(valb); + PyObject *keystr = PyObject_Str(key); + if(keystr!=NULL){ + PyObject *valstr = PyObject_Str(value); + if(valstr!=NULL){ + PyObject * keyb = PyObject_CallMethod(six,"b","O",keystr); + if(keyb!=NULL){ + PyObject * valb = PyObject_CallMethod(six,"b","O",valstr); + if(valb!=NULL){ + ret[PyBytes_AsString(keyb)] = PyBytes_AsString(valb); + Py_DECREF(valb); + } + Py_DECREF(keyb); + } + Py_DECREF(valstr); + } + Py_DECREF(keystr); + } + logPythonError(); } return ret; } -- cgit v1.2.3