@@ -976,6 +976,7 @@ typedef struct {
976976#if defined(HAVE_SCHED_SETPARAM ) || defined(HAVE_SCHED_SETSCHEDULER ) || defined(POSIX_SPAWN_SETSCHEDULER ) || defined(POSIX_SPAWN_SETSCHEDPARAM )
977977 PyObject * SchedParamType ;
978978#endif
979+ newfunc statresult_new_orig ;
979980 PyObject * StatResultType ;
980981 PyObject * StatVFSResultType ;
981982 PyObject * TerminalSizeType ;
@@ -2234,15 +2235,17 @@ statresult_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
22342235 PyStructSequence * result ;
22352236 int i ;
22362237
2237- PyObject * mod = PyType_GetModule (type );
2238+ // ht_module doesn't get set in PyStructSequence_NewType(),
2239+ // so we can't use PyType_GetModule().
2240+ PyObject * mod = PyImport_GetModule (MODNAME_OBJ );
22382241 if (mod == NULL ) {
22392242 return NULL ;
22402243 }
22412244 _posixstate * state = get_posix_state (mod );
22422245 if (state == NULL ) {
22432246 return NULL ;
22442247 }
2245- #define structseq_new ((PyTypeObject *) state->StatResultType)->tp_new
2248+ #define structseq_new state->statresult_new_orig;
22462249
22472250 result = (PyStructSequence * )structseq_new (type , args , kwds );
22482251 if (!result )
@@ -15936,6 +15939,7 @@ posixmodule_exec(PyObject *m)
1593615939 }
1593715940 PyModule_AddObject (m , "stat_result" , Py_NewRef (StatResultType ));
1593815941 state -> StatResultType = StatResultType ;
15942+ state -> statresult_new_orig = ((PyTypeObject * )StatResultType )-> tp_new ;
1593915943 ((PyTypeObject * )StatResultType )-> tp_new = statresult_new ;
1594015944
1594115945 statvfs_result_desc .name = "os.statvfs_result" ; /* see issue #19209 */
0 commit comments