summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo J. A. M. Carneiro <gjc@src.gnome.org>2005-12-24 12:39:28 +0000
committerGustavo J. A. M. Carneiro <gjc@src.gnome.org>2005-12-24 12:39:28 +0000
commitfe589b459de0d1d38a9e40966854da6c931c284a (patch)
tree229cc3eeeaf488bad9d67161d55ae7bf8feda495
parentae837b3cc01a2c7bc1cc5b90feee41a63ae7a611 (diff)
downloadpygobject-fe589b459de0d1d38a9e40966854da6c931c284a.tar.gz
pygobject-fe589b459de0d1d38a9e40966854da6c931c284a.tar.xz
pygobject-fe589b459de0d1d38a9e40966854da6c931c284a.zip
fix pygflags registration with module == NULL
-rw-r--r--gobject/pygflags.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/gobject/pygflags.c b/gobject/pygflags.c
index 00d9dd3..562ea02 100644
--- a/gobject/pygflags.c
+++ b/gobject/pygflags.c
@@ -214,14 +214,15 @@ pyg_flags_add (PyObject * module,
((PyTypeObject *)stub)->tp_flags &= ~Py_TPFLAGS_BASETYPE;
((PyTypeObject *)stub)->tp_new = pyg_flags_new;
- PyDict_SetItemString(((PyTypeObject *)stub)->tp_dict,
- "__module__",
- PyString_FromString(PyModule_GetName(module)));
+ if (module) {
+ PyDict_SetItemString(((PyTypeObject *)stub)->tp_dict,
+ "__module__",
+ PyString_FromString(PyModule_GetName(module)));
- /* Add it to the module name space */
- PyModule_AddObject(module, (char*)typename, stub);
- Py_INCREF(stub);
-
+ /* Add it to the module name space */
+ PyModule_AddObject(module, (char*)typename, stub);
+ Py_INCREF(stub);
+ }
g_type_set_qdata(gtype, pygflags_class_key, stub);
o = pyg_type_wrapper_new(gtype);
@@ -241,11 +242,13 @@ pyg_flags_add (PyObject * module,
PyDict_SetItem(values, PyInt_FromLong(eclass->values[i].value), item);
- PyModule_AddObject(module,
- pyg_constant_strip_prefix(eclass->values[i].value_name,
- strip_prefix),
- item);
- Py_INCREF(item);
+ if (module) {
+ PyModule_AddObject(module,
+ pyg_constant_strip_prefix(eclass->values[i].value_name,
+ strip_prefix),
+ item);
+ Py_INCREF(item);
+ }
}
PyDict_SetItemString(((PyTypeObject *)stub)->tp_dict,