Skip to content

Commit

Permalink
Merge pull request #418 from WillAyd/pep-489
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Aug 1, 2020
2 parents 7c987cc + a2143a3 commit 5dea5ef
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions python/ujson.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,30 @@ static PyMethodDef ujsonMethods[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};

static int ujson_exec(PyObject *module) {
PyModule_AddStringConstant(module, "__version__", UJSON_VERSION);
return 0;
}

static PyModuleDef_Slot ujson_slots[] = {
{Py_mod_exec, ujson_exec},
{0, NULL}
};

static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"ujson",
0, /* m_doc */
-1, /* m_size */
NULL, /* m_size */
ujsonMethods, /* m_methods */
NULL, /* m_reload */
ujson_slots, /* m_slots */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL /* m_free */
};

PyObject *PyInit_ujson(void)
{
PyObject *module;
PyObject *version_string;

initObjToJSON();
module = PyModule_Create(&moduledef);

if (module == NULL)
{
return NULL;
}

version_string = PyUnicode_FromString (UJSON_VERSION);
PyModule_AddObject (module, "__version__", version_string);

return module;
return PyModuleDef_Init(&moduledef);
}

0 comments on commit 5dea5ef

Please sign in to comment.