@@ -1291,59 +1291,55 @@ static PyMethodDef module_methods[] = {
1291
1291
{NULL , NULL } /* sentinel */
1292
1292
};
1293
1293
1294
- static struct PyModuleDef module_def = {
1295
- PyModuleDef_HEAD_INIT ,
1296
- "faulthandler" ,
1297
- module_doc ,
1298
- 0 , /* non-negative size to be able to unload the module */
1299
- module_methods ,
1300
- NULL ,
1301
- faulthandler_traverse ,
1302
- NULL ,
1303
- NULL
1304
- };
1305
-
1306
- PyMODINIT_FUNC
1307
- PyInit_faulthandler (void )
1308
- {
1309
- PyObject * m = PyModule_Create (& module_def );
1310
- if (m == NULL )
1311
- return NULL ;
1312
-
1294
+ static int
1295
+ PyExec_faulthandler (PyObject * module ) {
1313
1296
/* Add constants for unit tests */
1314
1297
#ifdef MS_WINDOWS
1315
1298
/* RaiseException() codes (prefixed by an underscore) */
1316
- if (PyModule_AddIntConstant (m , "_EXCEPTION_ACCESS_VIOLATION" ,
1299
+ if (PyModule_AddIntConstant (module , "_EXCEPTION_ACCESS_VIOLATION" ,
1317
1300
EXCEPTION_ACCESS_VIOLATION )) {
1318
- goto error ;
1301
+ return -1 ;
1319
1302
}
1320
- if (PyModule_AddIntConstant (m , "_EXCEPTION_INT_DIVIDE_BY_ZERO" ,
1303
+ if (PyModule_AddIntConstant (module , "_EXCEPTION_INT_DIVIDE_BY_ZERO" ,
1321
1304
EXCEPTION_INT_DIVIDE_BY_ZERO )) {
1322
- goto error ;
1305
+ return -1 ;
1323
1306
}
1324
- if (PyModule_AddIntConstant (m , "_EXCEPTION_STACK_OVERFLOW" ,
1307
+ if (PyModule_AddIntConstant (module , "_EXCEPTION_STACK_OVERFLOW" ,
1325
1308
EXCEPTION_STACK_OVERFLOW )) {
1326
- goto error ;
1309
+ return -1 ;
1327
1310
}
1328
1311
1329
1312
/* RaiseException() flags (prefixed by an underscore) */
1330
- if (PyModule_AddIntConstant (m , "_EXCEPTION_NONCONTINUABLE" ,
1313
+ if (PyModule_AddIntConstant (module , "_EXCEPTION_NONCONTINUABLE" ,
1331
1314
EXCEPTION_NONCONTINUABLE )) {
1332
- goto error ;
1315
+ return -1 ;
1333
1316
}
1334
- if (PyModule_AddIntConstant (m , "_EXCEPTION_NONCONTINUABLE_EXCEPTION" ,
1317
+ if (PyModule_AddIntConstant (module , "_EXCEPTION_NONCONTINUABLE_EXCEPTION" ,
1335
1318
EXCEPTION_NONCONTINUABLE_EXCEPTION )) {
1336
- goto error ;
1319
+ return -1 ;
1337
1320
}
1338
1321
#endif
1322
+ return 0 ;
1323
+ }
1339
1324
1340
- return m ;
1325
+ static PyModuleDef_Slot faulthandler_slots [] = {
1326
+ {Py_mod_exec , PyExec_faulthandler },
1327
+ {0 , NULL }
1328
+ };
1341
1329
1342
- #ifdef MS_WINDOWS
1343
- error :
1344
- Py_DECREF (m );
1345
- return NULL ;
1346
- #endif
1330
+ static struct PyModuleDef module_def = {
1331
+ PyModuleDef_HEAD_INIT ,
1332
+ .m_name = "faulthandler" ,
1333
+ .m_doc = module_doc ,
1334
+ .m_methods = module_methods ,
1335
+ .m_traverse = faulthandler_traverse ,
1336
+ .m_slots = faulthandler_slots
1337
+ };
1338
+
1339
+ PyMODINIT_FUNC
1340
+ PyInit_faulthandler (void )
1341
+ {
1342
+ return PyModuleDef_Init (& module_def );
1347
1343
}
1348
1344
1349
1345
static int
0 commit comments