Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 188078c

Browse filesBrowse files
authored
Revert "bpo-1635741: Port _weakref extension module to multiphase initialization (PEP 489) (GH-19084)" (#19128)
bpo-1635741, bpo-40050: This reverts commit 8334f30.
1 parent 7979298 commit 188078c
Copy full SHA for 188078c

File tree

1 file changed

+21
-37
lines changed
Filter options

1 file changed

+21
-37
lines changed

‎Modules/_weakref.c

Copy file name to clipboardExpand all lines: Modules/_weakref.c
+21-37Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -136,48 +136,14 @@ weakref_functions[] = {
136136
{NULL, NULL, 0, NULL}
137137
};
138138

139-
static int
140-
weakref_exec(PyObject *module)
141-
{
142-
Py_INCREF(&_PyWeakref_RefType);
143-
if (PyModule_AddObject(module, "ref", (PyObject *) &_PyWeakref_RefType) < 0) {
144-
Py_DECREF(&_PyWeakref_RefType);
145-
return -1;
146-
}
147-
Py_INCREF(&_PyWeakref_RefType);
148-
if (PyModule_AddObject(module, "ReferenceType",
149-
(PyObject *) &_PyWeakref_RefType) < 0) {
150-
Py_DECREF(&_PyWeakref_RefType);
151-
return -1;
152-
}
153-
Py_INCREF(&_PyWeakref_ProxyType);
154-
if (PyModule_AddObject(module, "ProxyType",
155-
(PyObject *) &_PyWeakref_ProxyType) < 0) {
156-
Py_DECREF(&_PyWeakref_ProxyType);
157-
return -1;
158-
}
159-
Py_INCREF(&_PyWeakref_CallableProxyType);
160-
if (PyModule_AddObject(module, "CallableProxyType",
161-
(PyObject *) &_PyWeakref_CallableProxyType) < 0) {
162-
Py_DECREF(&_PyWeakref_CallableProxyType);
163-
return -1;
164-
}
165-
166-
return 0;
167-
}
168-
169-
static struct PyModuleDef_Slot weakref_slots[] = {
170-
{Py_mod_exec, weakref_exec},
171-
{0, NULL}
172-
};
173139

174140
static struct PyModuleDef weakrefmodule = {
175141
PyModuleDef_HEAD_INIT,
176142
"_weakref",
177143
"Weak-reference support module.",
178-
0,
144+
-1,
179145
weakref_functions,
180-
weakref_slots,
146+
NULL,
181147
NULL,
182148
NULL,
183149
NULL
@@ -186,5 +152,23 @@ static struct PyModuleDef weakrefmodule = {
186152
PyMODINIT_FUNC
187153
PyInit__weakref(void)
188154
{
189-
return PyModuleDef_Init(&weakrefmodule);
155+
PyObject *m;
156+
157+
m = PyModule_Create(&weakrefmodule);
158+
159+
if (m != NULL) {
160+
Py_INCREF(&_PyWeakref_RefType);
161+
PyModule_AddObject(m, "ref",
162+
(PyObject *) &_PyWeakref_RefType);
163+
Py_INCREF(&_PyWeakref_RefType);
164+
PyModule_AddObject(m, "ReferenceType",
165+
(PyObject *) &_PyWeakref_RefType);
166+
Py_INCREF(&_PyWeakref_ProxyType);
167+
PyModule_AddObject(m, "ProxyType",
168+
(PyObject *) &_PyWeakref_ProxyType);
169+
Py_INCREF(&_PyWeakref_CallableProxyType);
170+
PyModule_AddObject(m, "CallableProxyType",
171+
(PyObject *) &_PyWeakref_CallableProxyType);
172+
}
173+
return m;
190174
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.