Skip to content
Snippets Groups Projects
Commit a9cf7232 authored by Florent Lamiraux's avatar Florent Lamiraux Committed by Florent Lamiraux florent@laas.fr
Browse files

Fix bug in getCommandDocstring.

    When help was invoked with a wrong command name, the interpreter failed with
    segmentation fault.
parent 4657223e
No related branches found
No related tags found
No related merge requests found
......@@ -294,15 +294,20 @@ namespace dynamicgraph {
}
void* pointer = PyCObject_AsVoidPtr(object);
Entity* entity = (Entity*)pointer;
typedef std::map<const std::string, command::Command*> CommandMap;
CommandMap map = entity->getNewStyleCommandMap();
typedef std::map<const std::string, command::Command*> commandMap_t;
typedef std::map<const std::string, command::Command*>::iterator
iterator_t;
commandMap_t map = entity->getNewStyleCommandMap();
command::Command* command = NULL;
try {
command = map[commandName];
} catch (const std::exception& exc) {
PyErr_SetString(dgpyError, exc.what());
iterator_t it = map.find(commandName);
if (it == map.end()) {
std::ostringstream oss;
oss << "'" << entity->getName() << "' entity has no command '"
<< commandName << "'.";
PyErr_SetString(PyExc_AttributeError, oss.str().c_str());
return NULL;
}
command = it->second;
std::string docstring = command->getDocstring();
return Py_BuildValue("s", docstring.c_str());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment