Skip to content

Commit 3cc5ae5

Browse files
authored
gh-85283: Convert grp extension to the limited C API (#116611)
posixmodule.h: remove check on the limited C API, since these helpers are not part of the public C API.
1 parent ba13215 commit 3cc5ae5

8 files changed

+20
-88
lines changed

Include/internal/pycore_global_objects_fini_generated.h

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ struct _Py_global_strings {
472472
STRUCT_FOR_ID(hi)
473473
STRUCT_FOR_ID(hook)
474474
STRUCT_FOR_ID(hour)
475-
STRUCT_FOR_ID(id)
476475
STRUCT_FOR_ID(ident)
477476
STRUCT_FOR_ID(identity_hint)
478477
STRUCT_FOR_ID(ignore)

Include/internal/pycore_runtime_init_generated.h

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/grpmodule.c.h

+11-75
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/grpmodule.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
21
/* UNIX group file access module */
32

4-
// clinic/grpmodule.c.h uses internal pycore_modsupport.h API
5-
#ifndef Py_BUILD_CORE_BUILTIN
6-
# define Py_BUILD_CORE_MODULE 1
3+
// Need limited C API version 3.13 for PyMem_RawRealloc()
4+
#include "pyconfig.h" // Py_GIL_DISABLED
5+
#ifndef Py_GIL_DISABLED
6+
#define Py_LIMITED_API 0x030d0000
77
#endif
88

99
#include "Python.h"
1010
#include "posixmodule.h"
1111

12+
#include <errno.h> // ERANGE
1213
#include <grp.h> // getgrgid_r()
14+
#include <string.h> // memcpy()
1315
#include <unistd.h> // sysconf()
1416

1517
#include "clinic/grpmodule.c.h"
@@ -88,7 +90,7 @@ mkgrent(PyObject *module, struct group *p)
8890
Py_DECREF(x);
8991
}
9092

91-
#define SET(i,val) PyStructSequence_SET_ITEM(v, i, val)
93+
#define SET(i,val) PyStructSequence_SetItem(v, i, val)
9294
SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_name));
9395
if (p->gr_passwd)
9496
SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_passwd));

Modules/posixmodule.h

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#ifndef Py_POSIXMODULE_H
44
#define Py_POSIXMODULE_H
5-
#ifndef Py_LIMITED_API
65
#ifdef __cplusplus
76
extern "C" {
87
#endif
@@ -34,5 +33,4 @@ extern int _Py_Sigset_Converter(PyObject *, void *);
3433
#ifdef __cplusplus
3534
}
3635
#endif
37-
#endif // !Py_LIMITED_API
3836
#endif // !Py_POSIXMODULE_H

Tools/c-analyzer/cpython/ignored.tsv

+2
Original file line numberDiff line numberDiff line change
@@ -740,3 +740,5 @@ Modules/expat/xmlrole.c - error -
740740
Modules/_io/_iomodule.c - _PyIO_Module -
741741
Modules/_sqlite/module.c - _sqlite3module -
742742
Modules/clinic/md5module.c.h _md5_md5 _keywords -
743+
Modules/clinic/grpmodule.c.h grp_getgrgid _keywords -
744+
Modules/clinic/grpmodule.c.h grp_getgrnam _keywords -

0 commit comments

Comments
 (0)