@@ -136,48 +136,14 @@ weakref_functions[] = {
136
136
{NULL , NULL , 0 , NULL }
137
137
};
138
138
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
- };
173
139
174
140
static struct PyModuleDef weakrefmodule = {
175
141
PyModuleDef_HEAD_INIT ,
176
142
"_weakref" ,
177
143
"Weak-reference support module." ,
178
- 0 ,
144
+ -1 ,
179
145
weakref_functions ,
180
- weakref_slots ,
146
+ NULL ,
181
147
NULL ,
182
148
NULL ,
183
149
NULL
@@ -186,5 +152,23 @@ static struct PyModuleDef weakrefmodule = {
186
152
PyMODINIT_FUNC
187
153
PyInit__weakref (void )
188
154
{
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 ;
190
174
}
0 commit comments