@@ -4600,6 +4600,35 @@ static PyMethodDef _surface_methods[] = {{NULL, NULL, 0, NULL}};
46004600int
46014601exec_surface (PyObject * module )
46024602{
4603+ /* imported needed apis; Do this first so if there is an error
4604+ the module is not loaded.
4605+ */
4606+ import_pygame_base ();
4607+ if (PyErr_Occurred ()) {
4608+ return -1 ;
4609+ }
4610+ import_pygame_color ();
4611+ if (PyErr_Occurred ()) {
4612+ return -1 ;
4613+ }
4614+ import_pygame_rect ();
4615+ if (PyErr_Occurred ()) {
4616+ return -1 ;
4617+ }
4618+ import_pygame_bufferproxy ();
4619+ if (PyErr_Occurred ()) {
4620+ return -1 ;
4621+ }
4622+ _IMPORT_PYGAME_MODULE (surflock );
4623+ if (PyErr_Occurred ()) {
4624+ return -1 ;
4625+ }
4626+
4627+ /* type preparation */
4628+ if (PyType_Ready (& pgSurface_Type ) < 0 ) {
4629+ return -1 ;
4630+ }
4631+
46034632 PyObject * apiobj ;
46044633 static void * c_api [PYGAMEAPI_SURFACE_NUMSLOTS ];
46054634
@@ -4658,34 +4687,5 @@ MODINIT_DEFINE(surface)
46584687 NULL ,
46594688 NULL };
46604689
4661- /* imported needed apis; Do this first so if there is an error
4662- the module is not loaded.
4663- */
4664- import_pygame_base ();
4665- if (PyErr_Occurred ()) {
4666- return NULL ;
4667- }
4668- import_pygame_color ();
4669- if (PyErr_Occurred ()) {
4670- return NULL ;
4671- }
4672- import_pygame_rect ();
4673- if (PyErr_Occurred ()) {
4674- return NULL ;
4675- }
4676- import_pygame_bufferproxy ();
4677- if (PyErr_Occurred ()) {
4678- return NULL ;
4679- }
4680- _IMPORT_PYGAME_MODULE (surflock );
4681- if (PyErr_Occurred ()) {
4682- return NULL ;
4683- }
4684-
4685- /* type preparation */
4686- if (PyType_Ready (& pgSurface_Type ) < 0 ) {
4687- return NULL ;
4688- }
4689-
46904690 return PyModuleDef_Init (& _module );
46914691}
0 commit comments