Fix for bug #966623 - classes created with type() in an exec(, {}) don't
have a __module__. Test for this case.

Bugfix candidate, will backport.
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 818572f..ee6e5d9 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -87,6 +87,10 @@
 
 	if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) {
 		mod = PyDict_GetItemString(type->tp_dict, "__module__");
+		if (!mod) { 
+			PyErr_Format(PyExc_AttributeError, "__module__");
+			return 0;
+		}
 		Py_XINCREF(mod);
 		return mod;
 	}