2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-22 05:22:45 +00:00

automatic addition of __module__ to class dict

[SVN r14072]
This commit is contained in:
Ralf W. Grosse-Kunstleve
2002-06-03 18:35:59 +00:00
parent 16c391c78c
commit 7a832f1fdb
3 changed files with 15 additions and 2 deletions

View File

@@ -45,6 +45,17 @@ void module_base::add_type(ref x)
add((PyTypeObject*)x.release());
}
void module_base::generic_add_class(ref class_obj)
{
Py_INCREF(class_obj.get());
this->add_type(class_obj);
ref module_name(PyObject_GetAttrString(m_module.get(),
const_cast<char*>("__name__")));
int status = PyObject_SetAttrString(class_obj.get(),
const_cast<char*>("__module__"), module_name.get());
if (status == -1) throw_error_already_set();
}
PyMethodDef module_base::initial_methods[] = { { 0, 0, 0, 0 } };
}}} // namespace boost::python::detail