Import from package; Check for import errors and handle them

develop
RusAnon 2010-05-03 15:00:18 +11:00
parent f2fd748fc6
commit ff52803eff
1 changed files with 12 additions and 2 deletions

@ -61,7 +61,12 @@ static void DoImports()
{ {
if(FlagsModule == NULL) if(FlagsModule == NULL)
{ {
FlagsModule = PyImport_ImportModule("pydfhackflags"); FlagsModule = PyImport_ImportModule("pydfhack.pydfhackflags");
if (PyErr_Occurred())
{
PyErr_Print();
return ;
}
CreatureFlags1_type = PyObject_GetAttrString(FlagsModule, "CreatureFlags1"); CreatureFlags1_type = PyObject_GetAttrString(FlagsModule, "CreatureFlags1");
CreatureFlags2_type = PyObject_GetAttrString(FlagsModule, "CreatureFlags2"); CreatureFlags2_type = PyObject_GetAttrString(FlagsModule, "CreatureFlags2");
@ -72,7 +77,12 @@ static void DoImports()
} }
if(TypesModule == NULL) if(TypesModule == NULL)
{ {
TypesModule = PyImport_ImportModule("pydftypes"); TypesModule = PyImport_ImportModule("pydfhack.pydftypes");
if (PyErr_Occurred())
{
PyErr_Print();
return ;
}
Note_type = PyObject_GetAttrString(TypesModule, "Note"); Note_type = PyObject_GetAttrString(TypesModule, "Note");
Construction_type = PyObject_GetAttrString(TypesModule, "Construction"); Construction_type = PyObject_GetAttrString(TypesModule, "Construction");