Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f585bef

Browse files
committed
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.
1 parent 6be838a commit f585bef

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Modules/unicodedata.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,8 @@ initunicodedata(void)
463463
{
464464
PyObject *m, *d, *v;
465465

466-
m = Py_InitModule4(
467-
"unicodedata", unicodedata_functions,
468-
unicodedata_docstring, NULL, PYTHON_API_VERSION);
466+
m = Py_InitModule3(
467+
"unicodedata", unicodedata_functions, unicodedata_docstring);
469468
if (!m)
470469
return;
471470

@@ -475,7 +474,8 @@ initunicodedata(void)
475474

476475
/* Export C API */
477476
v = PyCObject_FromVoidPtr((void *) &hashAPI, NULL);
478-
PyDict_SetItemString(d, "ucnhash_CAPI", v);
479-
Py_XDECREF(v);
480-
477+
if (v != NULL) {
478+
PyDict_SetItemString(d, "ucnhash_CAPI", v);
479+
Py_DECREF(v);
480+
}
481481
}

0 commit comments

Comments
 (0)