@@ -132,7 +132,7 @@ grp_getgrgid_impl(PyObject *module, PyObject *id)
132
132
if (!_Py_Gid_Converter (id , & gid )) {
133
133
return NULL ;
134
134
}
135
- #if defined( HAVE_GETGRGID_R )
135
+ #ifdef HAVE_GETGRGID_R
136
136
int status ;
137
137
Py_ssize_t bufsize ;
138
138
/* Note: 'grp' will be used via pointer 'p' on getgrgid_r success. */
@@ -167,21 +167,17 @@ grp_getgrgid_impl(PyObject *module, PyObject *id)
167
167
}
168
168
169
169
Py_END_ALLOW_THREADS <
10000
/div>
170
- #elif defined( Py_GIL_DISABLED )
170
+ #else
171
171
static PyMutex getgrgid_mutex = {0 };
172
172
PyMutex_Lock (& getgrgid_mutex );
173
173
// The getgrgid() function need not be thread-safe.
174
174
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/getgrgid.html
175
175
p = getgrgid (gid );
176
+ #endif
176
177
if (p == NULL ) {
177
- // Unlock the mutex on error. The following error handling block will
178
- // handle the rest.
178
+ #ifndef HAVE_GETGRGID_R
179
179
PyMutex_Unlock (& getgrgid_mutex );
180
- }
181
- #else
182
- p = getgrgid (gid );
183
180
#endif
184
- if (p == NULL ) {
185
181
PyMem_RawFree (buf );
186
182
if (nomem == 1 ) {
187
183
return PyErr_NoMemory ();
@@ -194,9 +190,9 @@ grp_getgrgid_impl(PyObject *module, PyObject *id)
194
190
return NULL ;
195
191
}
196
192
retval = mkgrent (module , p );
197
- #if defined( HAVE_GETGRGID_R )
193
+ #ifdef HAVE_GETGRGID_R
198
194
PyMem_RawFree (buf );
199
- #elif defined( Py_GIL_DISABLED )
195
+ #else
200
196
PyMutex_Unlock (& getgrgid_mutex );
201
197
#endif
202
198
return retval ;
@@ -226,7 +222,7 @@ grp_getgrnam_impl(PyObject *module, PyObject *name)
226
222
/* check for embedded null bytes */
227
223
if (PyBytes_AsStringAndSize (bytes , & name_chars , NULL ) == -1 )
228
224
goto out ;
229
- #if defined( HAVE_GETGRNAM_R )
225
+ #ifdef HAVE_GETGRNAM_R
230
226
int status ;
231
227
Py_ssize_t bufsize ;
232
228
/* Note: 'grp' will be used via pointer 'p' on getgrnam_r success. */
@@ -261,21 +257,17 @@ grp_getgrnam_impl(PyObject *module, PyObject *name)
261
257
}
262
258
263
259
Py_END_ALLOW_THREADS
264
- #elif defined( Py_GIL_DISABLED )
260
+ #else
265
261
static PyMutex getgrnam_mutex = {0 };
266
262
PyMutex_Lock (& getgrnam_mutex );
267
263
// The getgrnam() function need not be thread-safe.
268
264
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/getgrnam.html
269
265
p = getgrnam (name_chars );
266
+ #endif
270
267
if (p == NULL ) {
271
- // Unlock the mutex on error. The following error handling block will
272
- // handle the rest.
268
+ #ifndef HAVE_GETGRGID_R
273
269
PyMutex_Unlock (& getgrnam_mutex );
274
- }
275
- #else
276
- p = getgrnam (name_chars );
277
270
#endif
278
- if (p == NULL ) {
279
271
if (nomem == 1 ) {
280
272
PyErr_NoMemory ();
281
273
}
@@ -285,7 +277,7 @@ grp_getgrnam_impl(PyObject *module, PyObject *name)
285
277
goto out ;
286
278
}
287
279
retval = mkgrent (module , p );
288
- #if !defined( HAVE_GETGRNAM_R ) && defined( Py_GIL_DISABLED )
280
+ #ifndef HAVE_GETGRNAM_R
289
281
PyMutex_Unlock (& getgrnam_mutex );
290
282
#endif
291
283
out :
0 commit comments