10000 bpo-1635741: Port _json extension module to multiphase initialization(PEP 489) by shihai1991 · Pull Request #17835 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-1635741: Port _json extension module to multiphase initialization(PEP 489) #17835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 15, 2020
Prev Previous commit
Next Next commit
Fix refcount bug
  • Loading branch information
shi hai committed Jan 9, 2020
commit 768b4898f04ef21d4db8943c82de4cc558e4489e
17 changes: 8 additions & 9 deletions Modules/_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -1866,24 +1866,23 @@ PyDoc_STRVAR(module_doc,
static int
_json_exec(PyObject *module)
{
if (PyType_Ready(&PyScannerType) < 0)
goto fail;
if (PyType_Ready(&PyEncoderType) < 0)
goto fail;
if (PyType_Ready(&PyScannerType) < 0) {
return -1;
}
if (PyType_Ready(&PyEncoderType) < 0) {
return -1;
}
Py_INCREF((PyObject*)&PyScannerType);
if (PyModule_AddObject(module, "make_scanner", (PyObject*)&PyScannerType) < 0) {
Py_DECREF((PyObject*)&PyScannerType);
goto fail;
return -1;
}
Py_INCREF((PyObject*)&PyEncoderType);
if (PyModule_AddObject(module, "make_encoder", (PyObject*)&PyEncoderType) < 0) {
Py_DECREF((PyObject*)&PyEncoderType);
goto fail;
return -1;
}
return 0;
fail:
Py_DECREF(module);
return -1;
}

static PyModuleDef_Slot _json_slots[] = {
Expand Down
0