@@ -15849,42 +15849,34 @@ posixmodule_exec(PyObject *m)
15849
15849
if (setup_confname_tables (m ))
15850
15850
return -1 ;
15851
15851
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
+ }
15854
15855
15855
15856
#if defined(HAVE_WAITID ) && !defined(__APPLE__ )
15856
15857
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 ) {
15859
15860
return -1 ;
15860
15861
}
15861
- Py_INCREF (WaitidResultType );
15862
- PyModule_AddObject (m , "waitid_result" , WaitidResultType );
15863
- state -> WaitidResultType = WaitidResultType ;
15864
15862
#endif
15865
15863
15866
15864
stat_result_desc .name = "os.stat_result" ; /* see issue #19209 */
15867
15865
stat_result_desc .fields [7 ].name = PyStructSequence_UnnamedField ;
15868
15866
stat_result_desc .fields [8 ].name = PyStructSequence_UnnamedField ;
15869
15867
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 ) {
15872
15870
return -1 ;
15873
15871
}
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 ;
15879
15874
15880
15875
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 ) {
15883
15878
return -1 ;
15884
15879
}
15885
- Py_INCREF (StatVFSResultType );
15886
- PyModule_AddObject (m , "statvfs_result" , StatVFSResultType );
15887
- state -> StatVFSResultType = StatVFSResultType ;
15888
15880
#ifdef NEED_TICKS_PER_SECOND
15889
15881
# if defined(HAVE_SYSCONF ) && defined(_SC_CLK_TCK )
15890
15882
ticks_per_second = sysconf (_SC_CLK_TCK );
@@ -15897,24 +15889,18 @@ posixmodule_exec(PyObject *m)
15897
15889
15898
15890
#if defined(HAVE_SCHED_SETPARAM ) || defined(HAVE_SCHED_SETSCHEDULER ) || defined(POSIX_SPAWN_SETSCHEDULER ) || defined(POSIX_SPAWN_SETSCHEDPARAM )
15899
15891
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 ) {
15902
15894
return -1 ;
15903
15895
}
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 ;
15908
15897
#endif
15909
15898
15910
15899
/* 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 ) {
15913
15902
return -1 ;
15914
15903
}
15915
- Py_INCREF (TerminalSizeType );
15916
- PyModule_AddObject (m , "terminal_size" , TerminalSizeType );
15917
- state -> TerminalSizeType = TerminalSizeType ;
15918
15904
15919
15905
/* initialize scandir types */
15920
15906
PyObject * ScandirIteratorType = PyType_FromModuleAndSpec (m , & ScandirIteratorType_spec , NULL );
@@ -15923,30 +15909,21 @@ posixmodule_exec(PyObject *m)
15923
15909
}
15924
15910
state -> ScandirIteratorType = ScandirIteratorType ;
15925
15911
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 ) {
15928
15914
return -1 ;
15929
15915
}
15930
- Py_INCREF (DirEntryType );
15931
- PyModule_AddObject (m , "DirEntry" , DirEntryType );
15932
- state -> DirEntryType = DirEntryType ;
15933
15916
15934
15917
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 ) {
15937
15920
return -1 ;
15938
15921
}
15939
- Py_INCREF (TimesResultType );
15940
- PyModule_AddObject (m , "times_result" , TimesResultType );
15941
- state -> TimesResultType = TimesResultType ;
15942
15922
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 ) {
15945
15925
return -1 ;
15946
15926
}
15947
- Py_INCREF (UnameResultType );
15948
- PyModule_AddObject (m , "uname_result" , (PyObject * )UnameResultType );
15949
- state -> UnameResultType = (PyObject * )UnameResultType ;
15950
15927
15951
15928
if ((state -> billion = PyLong_FromLong (1000000000 )) == NULL )
15952
15929
return -1 ;
0 commit comments