From: Fred Drake <fdrake@acm.org>
Date: Sat, 3 Mar 2001 19:41:55 +0000 (+0000)
Subject: Be a bit more strict in setting up the export of the C API for this
X-Git-Tag: v2.1b2~237
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f585bef5043972b042cb324e75c82ee07fd56fa2;p=python

Be a bit more strict in setting up the export of the C API for this
module; do not attempt to insert the API object into the module dict
if there was an error creating it.
---

diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c
index 56c9466dbb..69345ea32b 100644
--- a/Modules/unicodedata.c
+++ b/Modules/unicodedata.c
@@ -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);
+    }
 }