@@ -2101,48 +2101,50 @@ statresult_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
2101
2101
static int
2102
2102
_posix_clear (PyObject * module )
2103
2103
{
2104
- Py_CLEAR (get_posix_state (module )-> billion );
2105
- Py_CLEAR (get_posix_state (module )-> DirEntryType );
2106
- Py_CLEAR (get_posix_state (module )-> ScandirIteratorType );
2104
+ _posixstate * state = get_posix_state (module );
2105
+ Py_CLEAR (state -> billion );
2106
+ Py_CLEAR (state -> DirEntryType );
2107
+ Py_CLEAR (state -> ScandirIteratorType );
2107
2108
#if defined(HAVE_SCHED_SETPARAM ) || defined(HAVE_SCHED_SETSCHEDULER ) || defined(POSIX_SPAWN_SETSCHEDULER ) || defined(POSIX_SPAWN_SETSCHEDPARAM )
2108
- Py_CLEAR (get_posix_state ( module ) -> SchedParamType );
2109
+ Py_CLEAR (state -> SchedParamType );
2109
2110
#endif
2110
- Py_CLEAR (get_posix_state ( module ) -> StatResultType );
2111
- Py_CLEAR (get_posix_state ( module ) -> StatVFSResultType );
2112
- Py_CLEAR (get_posix_state ( module ) -> TerminalSizeType );
2113
- Py_CLEAR (get_posix_state ( module ) -> TimesResultType );
2114
- Py_CLEAR (get_posix_state ( module ) -> UnameResultType );
2111
+ Py_CLEAR (state -> StatResultType );
2112
+ Py_CLEAR (state -> StatVFSResultType );
2113
+ Py_CLEAR (state -> TerminalSizeType );
2114
+ Py_CLEAR (state -> TimesResultType );
2115
+ Py_CLEAR (state -> UnameResultType );
2115
2116
#if defined(HAVE_WAITID ) && !defined(__APPLE__ )
2116
- Py_CLEAR (get_posix_state ( module ) -> WaitidResultType );
2117
+ Py_CLEAR (state -> WaitidResultType );
2117
2118
#endif
2118
2119
#if defined(HAVE_WAIT3 ) || defined(HAVE_WAIT4 )
2119
- Py_CLEAR (get_posix_state ( module ) -> struct_rusage );
2120
+ Py_CLEAR (state -> struct_rusage );
2120
2121
#endif
2121
- Py_CLEAR (get_posix_state ( module ) -> st_mode );
2122
+ Py_CLEAR (state -> st_mode );
2122
2123
return 0 ;
2123
2124
}
2124
2125
2125
2126
static int
2126
2127
_posix_traverse (PyObject * module , visitproc visit , void * arg )
2127
2128
{
2128
- Py_VISIT (get_posix_state (module )-> billion );
2129
- Py_VISIT (get_posix_state (module )-> DirEntryType );
2130
- Py_VISIT (get_posix_state (module )-> ScandirIteratorType );
2129
+ _posixstate * state = get_posix_state (module );
2130
+ Py_VISIT (state -> billion );
2131
+ Py_VISIT (state -> DirEntryType );
2132
+ Py_VISIT (state -> ScandirIteratorType );
2131
2133
#if defined(HAVE_SCHED_SETPARAM ) || defined(HAVE_SCHED_SETSCHEDULER ) || defined(POSIX_SPAWN_SETSCHEDULER ) || defined(POSIX_SPAWN_SETSCHEDPARAM )
2132
- Py_VISIT (get_posix_state ( module ) -> SchedParamType );
2134
+ Py_VISIT (state -> SchedParamType );
2133
2135
#endif
2134
- Py_VISIT (get_posix_state ( module ) -> StatResultType );
2135
- Py_VISIT (get_posix_state ( module ) -> StatVFSResultType );
2136
- Py_VISIT (get_posix_state ( module ) -> TerminalSizeType );
2137
- Py_VISIT (get_posix_state ( module ) -> TimesResultType );
2138
- Py_VISIT (get_posix_state ( module ) -> UnameResultType );
2136
+ Py_VISIT (state -> StatResultType );
2137
+ Py_VISIT (state -> StatVFSResultType );
2138
+ Py_VISIT (state -> TerminalSizeType );
2139
+ Py_VISIT (state -> TimesResultType );
2140
+ Py_VISIT (state -> UnameResultType );
2139
2141
#if defined(HAVE_WAITID ) && !defined(__APPLE__ )
2140
- Py_VISIT (get_posix_state ( module ) -> WaitidResultType );
2142
+ Py_VISIT (state -> WaitidResultType );
2141
2143
#endif
2142
2144
#if defined(HAVE_WAIT3 ) || defined(HAVE_WAIT4 )
2143
- Py_VISIT (get_posix_state ( module ) -> struct_rusage );
2145
+ Py_VISIT (state -> struct_rusage );
2144
2146
#endif
2145
- Py_VISIT (get_posix_state ( module ) -> st_mode );
2147
+ Py_VISIT (state -> st_mode );
2146
2148
return 0 ;
2147
2149
}
2148
2150
@@ -12777,8 +12779,7 @@ os_DirEntry_is_symlink_impl(DirEntry *self, PyTypeObject *defining_class)
12777
12779
}
12778
12780
12779
12781
static PyObject *
12780
- DirEntry_fetch_stat (PyTypeObject * defining_class , DirEntry * self ,
12781
- int follow_symlinks )
12782
+ DirEntry_fetch_stat (PyObject * module , DirEntry * self , int follow_symlinks )
12782
12783
{
12783
12784
int result ;
12784
12785
STRUCT_STAT st ;
@@ -12814,18 +12815,18 @@ DirEntry_fetch_stat(PyTypeObject *defining_class, DirEntry *self,
12814
12815
if (result != 0 )
12815
12816
return path_object_error (self -> path );
12816
12817
12817
- return _pystat_fromstructstat (PyType_GetModule ( defining_class ) , & st );
12818
+ return _pystat_fromstructstat (module , & st );
12818
12819
}
12819
12820
12820
12821
static PyObject *
12821
12822
DirEntry_get_lstat (PyTypeObject * defining_class , DirEntry * self )
12822
12823
{
12823
12824
if (!self -> lstat ) {
12825
+ PyObject * module = PyType_GetModule (defining_class );
12824
12826
#ifdef MS_WINDOWS
12825
- self -> lstat = _pystat_fromstructstat (PyType_GetModule (defining_class ),
12826
- & self -> win32_lstat );
12827
+ self -> lstat = _pystat_fromstructstat (module , & self -> win32_lstat );
12827
12828
#else /* POSIX */
12828
- self -> lstat = DirEntry_fetch_stat (defining_class , self , 0 );
12829
+ self -> lstat = DirEntry_fetch_stat (module , self , 0 );
12829
12830
#endif
12830
12831
}
12831
12832
Py_XINCREF (self -> lstat );
@@ -12857,7 +12858,8 @@ os_DirEntry_stat_impl(DirEntry *self, PyTypeObject *defining_class,
12857
12858
return NULL ;
12858
12859
}
12859
12860
if (result ) {
12860
- self -> stat = DirEntry_fetch_stat (defining_class , self , 1 );
12861
+ PyObject * module = PyType_GetModule (defining_class );
12862
+ self -> stat = DirEntry_fetch_stat (module , self , 1 );
12861
12863
}
12862
12864
else {
12863
12865
self -> stat = DirEntry_get_lstat (defining_class , self );
@@ -12906,7 +12908,8 @@ DirEntry_test_mode(PyTypeObject *defining_class, DirEntry *self,
12906
12908
}
12907
12909
goto error ;
12908
12910
}
12909
- st_mode = PyObject_GetAttr (stat , get_posix_state (PyType_GetModule (defining_class ))-> st_mode );
12911
+ _posixstate * state = get_posix_state (PyType_GetModule (defining_class ));
12912
+ st_mode = PyObject_GetAttr (stat , state -> st_mode );
12910
12913
if (!st_mode )
12911
12914
goto error ;
12912
12915
0 commit comments