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

Skip to content

Commit a2bd8d3

Browse files
committed
Remove direct manipulation of the module dict.
1 parent 8f3078b commit a2bd8d3

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

Modules/unicodedata.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -463,21 +463,15 @@ static char *unicodedata_docstring = "unicode character database";
463463
DL_EXPORT(void)
464464
initunicodedata(void)
465465
{
466-
PyObject *m, *d, *v;
466+
PyObject *m, *v;
467467

468468
m = Py_InitModule3(
469469
"unicodedata", unicodedata_functions, unicodedata_docstring);
470470
if (!m)
471471
return;
472472

473-
d = PyModule_GetDict(m);
474-
if (!d)
475-
return;
476-
477473
/* Export C API */
478474
v = PyCObject_FromVoidPtr((void *) &hashAPI, NULL);
479-
if (v != NULL) {
480-
PyDict_SetItemString(d, "ucnhash_CAPI", v);
481-
Py_DECREF(v);
482-
}
475+
if (v != NULL)
476+
PyModule_AddObject(m, "ucnhash_CAPI", v);
483477
}

0 commit comments

Comments
 (0)