]> granicus.if.org Git - python/commitdiff
Be a bit more strict in setting up the export of the C API for this
authorFred Drake <fdrake@acm.org>
Sat, 3 Mar 2001 19:41:55 +0000 (19:41 +0000)
committerFred Drake <fdrake@acm.org>
Sat, 3 Mar 2001 19:41:55 +0000 (19:41 +0000)
module; do not attempt to insert the API object into the module dict
if there was an error creating it.

Modules/unicodedata.c

index 56c9466dbbed589540a08636190d401951bf294c..69345ea32b508b72d81291ad3f61c682a8828d83 100644 (file)
@@ -463,9 +463,8 @@ initunicodedata(void)
 {
     PyObject *m, *d, *v;
 
-    m = Py_InitModule4(
-        "unicodedata", unicodedata_functions,
-        unicodedata_docstring, NULL, PYTHON_API_VERSION);
+    m = Py_InitModule3(
+        "unicodedata", unicodedata_functions, unicodedata_docstring);
     if (!m)
         return;
 
@@ -475,7 +474,8 @@ initunicodedata(void)
 
     /* Export C API */
     v = PyCObject_FromVoidPtr((void *) &hashAPI, NULL);
-    PyDict_SetItemString(d, "ucnhash_CAPI", v);
-    Py_XDECREF(v);
-
+    if (v != NULL) {
+        PyDict_SetItemString(d, "ucnhash_CAPI", v);
+        Py_DECREF(v);
+    }
 }