@@ -14802,12 +14802,10 @@ static const char * const have_functions[] = {
14802
14802
static int
14803
14803
posixmodule_exec (PyObject * m )
14804
14804
{
14805
- PyObject * v ;
14806
- PyObject * list ;
14807
- const char * const * trace ;
14805
+ _posixstate * state = get_posix_state (m );
14808
14806
14809
14807
/* Initialize environ dictionary */
14810
- v = convertenviron ();
14808
+ PyObject * v = convertenviron ();
14811
14809
Py_XINCREF (v );
14812
14810
if (v == NULL || PyModule_AddObject (m , "environ" , v ) != 0 )
14813
14811
return -1 ;
@@ -14830,7 +14828,7 @@ posixmodule_exec(PyObject *m)
14830
14828
}
14831
14829
Py_INCREF (WaitidResultType );
14832
14830
PyModule_AddObject (m , "waitid_result" , WaitidResultType );
14833
- get_posix_state ( m ) -> WaitidResultType = WaitidResultType ;
14831
+ state -> WaitidResultType = WaitidResultType ;
14834
14832
#endif
14835
14833
14836
14834
stat_result_desc .name = "os.stat_result" ; /* see issue #19209 */
@@ -14843,7 +14841,7 @@ posixmodule_exec(PyObject *m)
14843
14841
}
14844
14842
Py_INCREF (StatResultType );
14845
14843
PyModule_AddObject (m , "stat_result" , StatResultType );
14846
- get_posix_state ( m ) -> StatResultType = StatResultType ;
14844
+ state -> StatResultType = StatResultType ;
14847
14845
structseq_new = ((PyTypeObject * )StatResultType )-> tp_new ;
14848
14846
((PyTypeObject * )StatResultType )-> tp_new = statresult_new ;
14849
14847
@@ -14854,7 +14852,7 @@ posixmodule_exec(PyObject *m)
14854
14852
}
14855
14853
Py_INCREF (StatVFSResultType );
14856
14854
PyModule_AddObject (m , "statvfs_result" , StatVFSResultType );
14857
- get_posix_state ( m ) -> StatVFSResultType = StatVFSResultType ;
14855
+ state -> StatVFSResultType = StatVFSResultType ;
14858
14856
#ifdef NEED_TICKS_PER_SECOND
14859
14857
# if defined(HAVE_SYSCONF ) && defined(_SC_CLK_TCK )
14860
14858
ticks_per_second = sysconf (_SC_CLK_TCK );
@@ -14873,7 +14871,7 @@ posixmodule_exec(PyObject *m)
14873
14871
}
14874
14872
Py_INCREF (SchedParamType );
14875
14873
PyModule_AddObject (m , "sched_param" , SchedParamType );
14876
- get_posix_state ( m ) -> SchedParamType = SchedParamType ;
14874
+ state -> SchedParamType = SchedParamType ;
14877
14875
((PyTypeObject * )SchedParamType )-> tp_new = os_sched_param ;
14878
14876
#endif
14879
14877
@@ -14884,22 +14882,22 @@ posixmodule_exec(PyObject *m)
14884
14882
}
14885
14883
Py_INCREF (TerminalSizeType );
14886
14884
PyModule_AddObject (m , "terminal_size" , TerminalSizeType );
14887
- get_posix_state ( m ) -> TerminalSizeType = TerminalSizeType ;
14885
+ state -> TerminalSizeType = TerminalSizeType ;
14888
14886
14889
14887
/* initialize scandir types */
14890
14888
PyObject * ScandirIteratorType = PyType_FromModuleAndSpec (m , & ScandirIteratorType_spec , NULL );
14891
14889
if (ScandirIteratorType == NULL ) {
14892
14890
return -1 ;
14893
14891
}
14894
- get_posix_state ( m ) -> ScandirIteratorType = ScandirIteratorType ;
14892
+ state -> ScandirIteratorType = ScandirIteratorType ;
14895
14893
14896
14894
PyObject * DirEntryType = PyType_FromModuleAndSpec (m , & DirEntryType_spec , NULL );
14897
14895
if (DirEntryType == NULL ) {
14898
14896
return -1 ;
14899
14897
}
14900
14898
Py_INCREF (DirEntryType );
14901
14899
PyModule_AddObject (m , "DirEntry" , DirEntryType );
14902
- get_posix_state ( m ) -> DirEntryType = DirEntryType ;
14900
+ state -> DirEntryType = DirEntryType ;
14903
14901
14904
14902
times_result_desc .name = MODNAME ".times_result" ;
14905
14903
PyObject * TimesResultType = (PyObject * )PyStructSequence_NewType (& times_result_desc );
@@ -14908,15 +14906,15 @@ posixmodule_exec(PyObject *m)
14908
14906
}
14909
14907
Py_INCREF (TimesResultType );
14910
14908
PyModule_AddObject (m , "times_result" , TimesResultType );
14911
- get_posix_state ( m ) -> TimesResultType = TimesResultType ;
14909
+ state -> TimesResultType = TimesResultType ;
14912
14910
14913
14911
PyTypeObject * UnameResultType = PyStructSequence_NewType (& uname_result_desc );
14914
14912
if (UnameResultType == NULL ) {
14915
14913
return -1 ;
14916
14914
}
14917
14915
Py_INCREF (UnameResultType );
14918
14916
PyModule_AddObject (m , "uname_result" , (PyObject * )UnameResultType );
14919
- get_posix_state ( m ) -> UnameResultType = (PyObject * )UnameResultType ;
14917
+ state -> UnameResultType = (PyObject * )UnameResultType ;
14920
14918
14921
14919
#ifdef __APPLE__
14922
14920
/*
@@ -14956,15 +14954,15 @@ posixmodule_exec(PyObject *m)
14956
14954
14957
14955
#endif /* __APPLE__ */
14958
14956
14959
- if ((get_posix_state ( m ) -> billion = PyLong_FromLong (1000000000 )) == NULL )
14957
+ if ((state -> billion = PyLong_FromLong (1000000000 )) == NULL )
14960
14958
return -1 ;
14961
14959
#if defined(HAVE_WAIT3 ) || defined(HAVE_WAIT4 )
14962
- get_posix_state ( m ) -> struct_rusage = PyUnicode_InternFromString ("struct_rusage" );
14963
- if (get_posix_state ( m ) -> struct_rusage == NULL )
14960
+ state -> struct_rusage = PyUnicode_InternFromString ("struct_rusage" );
14961
+ if (state -> struct_rusage == NULL )
14964
14962
return -1 ;
14965
14963
#endif
14966
- get_posix_state ( m ) -> st_mode = PyUnicode_InternFromString ("st_mode" );
14967
- if (get_posix_state ( m ) -> st_mode == NULL )
14964
+ state -> st_mode = PyUnicode_InternFromString ("st_mode" );
14965
+ if (state -> st_mode == NULL )
14968
14966
return -1 ;
14969
14967
14970
14968
/* suppress "function not used" warnings */
@@ -14981,10 +14979,11 @@ posixmodule_exec(PyObject *m)
14981
14979
* provide list of locally available functions
14982
14980
* so os.py can populate support_* lists
14983
14981
*/
14984
- list = PyList_New (0 );
14985
- if (!list )
14982
+ PyObject * list = PyList_New (0 );
14983
+ if (!list ) {
14986
14984
return -1 ;
14987
- for (trace = have_functions ; * trace ; trace ++ ) {
14985
+ }
14986
+ for (const char * const * trace = have_functions ; * trace ; trace ++ ) {
14988
14987
PyObject * unicode = PyUnicode_DecodeASCII (* trace , strlen (* trace ), NULL );
14989
14988
if (!unicode )
14990
14989
return -1 ;
0 commit comments