diff options
author | Victor Stinner <vstinner@python.org> | 2020-03-23 23:48:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-23 23:48:03 (GMT) |
commit | 188078c39dec24aa5b3f2073bdc9a68ebaae42de (patch) | |
tree | 7bc5360d202f505ab259ea000f19fcf72457b167 /Modules/_weakref.c | |
parent | 7979298ec1d3ebedd775661f6ba4a1956db434a2 (diff) | |
download | cpython-188078c39dec24aa5b3f2073bdc9a68ebaae42de.zip cpython-188078c39dec24aa5b3f2073bdc9a68ebaae42de.tar.gz cpython-188078c39dec24aa5b3f2073bdc9a68ebaae42de.tar.bz2 |
Revert "bpo-1635741: Port _weakref extension module to multiphase initialization (PEP 489) (GH-19084)" (#19128)
bpo-1635741, bpo-40050: This reverts
commit 8334f30a74abcf7e469b901afc307887aa85a888.
Diffstat (limited to 'Modules/_weakref.c')
-rw-r--r-- | Modules/_weakref.c | 58 |
1 files changed, 21 insertions, 37 deletions
diff --git a/Modules/_weakref.c b/Modules/_weakref.c index cd7c4c1..c1238e0 100644 --- a/Modules/_weakref.c +++ b/Modules/_weakref.c @@ -136,48 +136,14 @@ weakref_functions[] = { {NULL, NULL, 0, NULL} }; -static int -weakref_exec(PyObject *module) -{ - Py_INCREF(&_PyWeakref_RefType); - if (PyModule_AddObject(module, "ref", (PyObject *) &_PyWeakref_RefType) < 0) { - Py_DECREF(&_PyWeakref_RefType); - return -1; - } - Py_INCREF(&_PyWeakref_RefType); - if (PyModule_AddObject(module, "ReferenceType", - (PyObject *) &_PyWeakref_RefType) < 0) { - Py_DECREF(&_PyWeakref_RefType); - return -1; - } - Py_INCREF(&_PyWeakref_ProxyType); - if (PyModule_AddObject(module, "ProxyType", - (PyObject *) &_PyWeakref_ProxyType) < 0) { - Py_DECREF(&_PyWeakref_ProxyType); - return -1; - } - Py_INCREF(&_PyWeakref_CallableProxyType); - if (PyModule_AddObject(module, "CallableProxyType", - (PyObject *) &_PyWeakref_CallableProxyType) < 0) { - Py_DECREF(&_PyWeakref_CallableProxyType); - return -1; - } - - return 0; -} - -static struct PyModuleDef_Slot weakref_slots[] = { - {Py_mod_exec, weakref_exec}, - {0, NULL} -}; static struct PyModuleDef weakrefmodule = { PyModuleDef_HEAD_INIT, "_weakref", "Weak-reference support module.", - 0, + -1, weakref_functions, - weakref_slots, + NULL, NULL, NULL, NULL @@ -186,5 +152,23 @@ static struct PyModuleDef weakrefmodule = { PyMODINIT_FUNC PyInit__weakref(void) { - return PyModuleDef_Init(&weakrefmodule); + PyObject *m; + + m = PyModule_Create(&weakrefmodule); + + if (m != NULL) { + Py_INCREF(&_PyWeakref_RefType); + PyModule_AddObject(m, "ref", + (PyObject *) &_PyWeakref_RefType); + Py_INCREF(&_PyWeakref_RefType); + PyModule_AddObject(m, "ReferenceType", + (PyObject *) &_PyWeakref_RefType); + Py_INCREF(&_PyWeakref_ProxyType); + PyModule_AddObject(m, "ProxyType", + (PyObject *) &_PyWeakref_ProxyType); + Py_INCREF(&_PyWeakref_CallableProxyType); + PyModule_AddObject(m, "CallableProxyType", + (PyObject *) &_PyWeakref_CallableProxyType); + } + return m; } |