Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
update code
  • Loading branch information
koubaa committed Jul 8, 2020
commit 1cba0bc10899e04e2a5c12b449d882fb1d8aa91a
24 changes: 18 additions & 6 deletions Modules/unicodedata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1426,9 +1426,8 @@ UnicodeData File Format " UNIDATA_VERSION ".");
static int unicodedata_exec(PyObject *m)
{
PyObject *v;
UnicodeDataState* st;

st = unicodedata_get_state(m);
UnicodeDataState *st = unicodedata_get_state(m);

st->ucd_type = (PyTypeObject *)PyType_FromModuleAndSpec(m, &unicodedata_ucd_type_spec, NULL);
if (st->ucd_type == NULL) {
Expand All @@ -1445,13 +1444,25 @@ static int unicodedata_exec(PyObject *m)

/* Previous versions */
v = new_previous_version(m, "3.2.0", get_change_3_2_0, normalization_3_2_0);
if (v != NULL)
PyModule_AddObject(m, "ucd_3_2_0", v);
if (v == NULL)
return -1;

if (PyModule_AddObject(m, "ucd_3_2_0", v) < 0) {
Py_DECREF(v);
return -1;
}

/* Export C API */
v = PyCapsule_New((void *)&hashAPI, PyUnicodeData_CAPSULE_NAME, NULL);
if (v != NULL)
PyModule_AddObject(m, "ucnhash_CAPI", v);
if (v == NULL)
return -1;

if (PyModule_AddObject(m, "ucnhash_CAPI", v) < 0)
{
Py_DECREF(v);
return -1;
}

return 0;
}

Expand All @@ -1463,6 +1474,7 @@ static PyModuleDef_Slot unicodedata_slots[] = {
static struct PyModuleDef unicodedata_module = {
PyModuleDef_HEAD_INIT,
.m_name = "unicodedata",
Comment thread
koubaa marked this conversation as resolved.
.m_doc = unicodedata_docstring,
.m_size = sizeof(UnicodeDataState),
.m_methods = unicodedata_functions,
.m_slots = unicodedata_slots,
Expand Down