Skip to content

Commit

Permalink
Fix strange bug, feel there is something else going on here
Browse files Browse the repository at this point in the history
-       int ret = PyDict_SetItem(YPython::_pMainDicts, pModuleName, PyModule_GetDict(pMain));
+       int ret = PyDict_SetItemString(YPython::_pMainDicts, module_name.c_str(), PyModule_GetDict(pMain));

Had to change the Dict access above because it didn't work from py3 when
getting called from ruby. OTOH it worked fined from python (where the python
client was calling import_module "aPythonModule"
  • Loading branch information
noelpower authored and dmulder committed Jan 17, 2019
1 parent 56b9940 commit eb1ca2e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/YPython.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,13 @@ YPython::loadModule(string module)
return YCPError("The module was not imported");
}

int ret = PyDict_SetItem(YPython::_pMainDicts, pModuleName, PyModule_GetDict(pMain));
/* Something is broken somewhere, with py3 this line doesn't
* work when called from ruby (as a result of import "PythonModule"
* However when called from python (e.g. import_module("PythonModule")
* it works.
*/
//int ret = PyDict_SetItem(YPython::_pMainDicts, pModuleName, PyModule_GetDict(pMain));
int ret = PyDict_SetItemString(YPython::_pMainDicts, module_name.c_str(), PyModule_GetDict(pMain));
if (ret != 0)
return YCPError("The module was not imported");
} else {
Expand Down

0 comments on commit eb1ca2e

Please sign in to comment.