@@ -15849,42 +15849,34 @@ posixmodule_exec(PyObject *m)
1584915849 if (setup_confname_tables (m ))
1585015850 return -1 ;
1585115851
15852- Py_INCREF (PyExc_OSError );
15853- PyModule_AddObject (m , "error" , PyExc_OSError );
15852+ if (PyModule_AddObjectRef (m , "error" , PyExc_OSError ) < 0 ) {
15853+ return -1 ;
15854+ }
1585415855
1585515856#if defined(HAVE_WAITID ) && !defined(__APPLE__ )
1585615857 waitid_result_desc .name = MODNAME ".waitid_result" ;
15857- PyObject * WaitidResultType = (PyObject * )PyStructSequence_NewType (& waitid_result_desc );
15858- if (WaitidResultType == NULL ) {
15858+ state -> WaitidResultType = (PyObject * )PyStructSequence_NewType (& waitid_result_desc );
15859+ if (PyModule_AddObjectRef ( m , "waitid_result" , state -> WaitidResultType ) < 0 ) {
1585915860 return -1 ;
1586015861 }
15861- Py_INCREF (WaitidResultType );
15862- PyModule_AddObject (m , "waitid_result" , WaitidResultType );
15863- state -> WaitidResultType = WaitidResultType ;
1586415862#endif
1586515863
1586615864 stat_result_desc .name = "os.stat_result" ; /* see issue #19209 */
1586715865 stat_result_desc .fields [7 ].name = PyStructSequence_UnnamedField ;
1586815866 stat_result_desc .fields [8 ].name = PyStructSequence_UnnamedField ;
1586915867 stat_result_desc .fields [9 ].name = PyStructSequence_UnnamedField ;
15870- PyObject * StatResultType = (PyObject * )PyStructSequence_NewType (& stat_result_desc );
15871- if (StatResultType == NULL ) {
15868+ state -> StatResultType = (PyObject * )PyStructSequence_NewType (& stat_result_desc );
15869+ if (PyModule_AddObjectRef ( m , "stat_result" , state -> StatResultType ) < 0 ) {
1587215870 return -1 ;
1587315871 }
15874- Py_INCREF (StatResultType );
15875- PyModule_AddObject (m , "stat_result" , StatResultType );
15876- state -> StatResultType = StatResultType ;
15877- structseq_new = ((PyTypeObject * )StatResultType )-> tp_new ;
15878- ((PyTypeObject * )StatResultType )-> tp_new = statresult_new ;
15872+ structseq_new = ((PyTypeObject * )state -> StatResultType )-> tp_new ;
15873+ ((PyTypeObject * )state -> StatResultType )-> tp_new = statresult_new ;
1587915874
1588015875 statvfs_result_desc .name = "os.statvfs_result" ; /* see issue #19209 */
15881- PyObject * StatVFSResultType = (PyObject * )PyStructSequence_NewType (& statvfs_result_desc );
15882- if (StatVFSResultType == NULL ) {
15876+ state -> StatVFSResultType = (PyObject * )PyStructSequence_NewType (& statvfs_result_desc );
15877+ if (PyModule_AddObjectRef ( m , "statvfs_result" , state -> StatVFSResultType ) < 0 ) {
1588315878 return -1 ;
1588415879 }
15885- Py_INCREF (StatVFSResultType );
15886- PyModule_AddObject (m , "statvfs_result" , StatVFSResultType );
15887- state -> StatVFSResultType = StatVFSResultType ;
1588815880#ifdef NEED_TICKS_PER_SECOND
1588915881# if defined(HAVE_SYSCONF ) && defined(_SC_CLK_TCK )
1589015882 ticks_per_second = sysconf (_SC_CLK_TCK );
@@ -15897,24 +15889,18 @@ posixmodule_exec(PyObject *m)
1589715889
1589815890#if defined(HAVE_SCHED_SETPARAM ) || defined(HAVE_SCHED_SETSCHEDULER ) || defined(POSIX_SPAWN_SETSCHEDULER ) || defined(POSIX_SPAWN_SETSCHEDPARAM )
1589915891 sched_param_desc .name = MODNAME ".sched_param" ;
15900- PyObject * SchedParamType = (PyObject * )PyStructSequence_NewType (& sched_param_desc );
15901- if (SchedParamType == NULL ) {
15892+ state -> SchedParamType = (PyObject * )PyStructSequence_NewType (& sched_param_desc );
15893+ if (PyModule_AddObjectRef ( m , "sched_param" , state -> SchedParamType ) < 0 ) {
1590215894 return -1 ;
1590315895 }
15904- Py_INCREF (SchedParamType );
15905- PyModule_AddObject (m , "sched_param" , SchedParamType );
15906- state -> SchedParamType = SchedParamType ;
15907- ((PyTypeObject * )SchedParamType )-> tp_new = os_sched_param ;
15896+ ((PyTypeObject * )state -> SchedParamType )-> tp_new = os_sched_param ;
1590815897#endif
1590915898
1591015899 /* initialize TerminalSize_info */
15911- PyObject * TerminalSizeType = (PyObject * )PyStructSequence_NewType (& TerminalSize_desc );
15912- if (TerminalSizeType == NULL ) {
15900+ state -> TerminalSizeType = (PyObject * )PyStructSequence_NewType (& TerminalSize_desc );
15901+ if (PyModule_AddObjectRef ( m , "terminal_size" , state -> TerminalSizeType ) < 0 ) {
1591315902 return -1 ;
1591415903 }
15915- Py_INCREF (TerminalSizeType );
15916- PyModule_AddObject (m , "terminal_size" , TerminalSizeType );
15917- state -> TerminalSizeType = TerminalSizeType ;
1591815904
1591915905 /* initialize scandir types */
1592015906 PyObject * ScandirIteratorType = PyType_FromModuleAndSpec (m , & ScandirIteratorType_spec , NULL );
@@ -15923,30 +15909,21 @@ posixmodule_exec(PyObject *m)
1592315909 }
1592415910 state -> ScandirIteratorType = ScandirIteratorType ;
1592515911
15926- PyObject * DirEntryType = PyType_FromModuleAndSpec (m , & DirEntryType_spec , NULL );
15927- if (DirEntryType == NULL ) {
15912+ state -> DirEntryType = PyType_FromModuleAndSpec (m , & DirEntryType_spec , NULL );
15913+ if (PyModule_AddObjectRef ( m , "DirEntry" , state -> DirEntryType ) < 0 ) {
1592815914 return -1 ;
1592915915 }
15930- Py_INCREF (DirEntryType );
15931- PyModule_AddObject (m , "DirEntry" , DirEntryType );
15932- state -> DirEntryType = DirEntryType ;
1593315916
1593415917 times_result_desc .name = MODNAME ".times_result" ;
15935- PyObject * TimesResultType = (PyObject * )PyStructSequence_NewType (& times_result_desc );
15936- if (TimesResultType == NULL ) {
15918+ state -> TimesResultType = (PyObject * )PyStructSequence_NewType (& times_result_desc );
15919+ if (PyModule_AddObjectRef ( m , "times_result" , state -> TimesResultType ) < 0 ) {
1593715920 return -1 ;
1593815921 }
15939- Py_INCREF (TimesResultType );
15940- PyModule_AddObject (m , "times_result" , TimesResultType );
15941- state -> TimesResultType = TimesResultType ;
1594215922
15943- PyTypeObject * UnameResultType = PyStructSequence_NewType (& uname_result_desc );
15944- if (UnameResultType == NULL ) {
15923+ state -> UnameResultType = ( PyObject * ) PyStructSequence_NewType (& uname_result_desc );
15924+ if (PyModule_AddObjectRef ( m , "uname_result" , state -> UnameResultType ) < 0 ) {
1594515925 return -1 ;
1594615926 }
15947- Py_INCREF (UnameResultType );
15948- PyModule_AddObject (m , "uname_result" , (PyObject * )UnameResultType );
15949- state -> UnameResultType = (PyObject * )UnameResultType ;
1595015927
1595115928 if ((state -> billion = PyLong_FromLong (1000000000 )) == NULL )
1595215929 return -1 ;
0 commit comments