Skip to content

Commit

Permalink
gh-85283: Convert grp extension to the limited C API (#116611)
Browse files Browse the repository at this point in the history
posixmodule.h: remove check on the limited C API, since these helpers
are not part of the public C API.
  • Loading branch information
vstinner committed Mar 12, 2024
1 parent ba13215 commit 3cc5ae5
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 88 deletions.
1 change: 0 additions & 1 deletion Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(hi)
STRUCT_FOR_ID(hook)
STRUCT_FOR_ID(hour)
STRUCT_FOR_ID(id)
STRUCT_FOR_ID(ident)
STRUCT_FOR_ID(identity_hint)
STRUCT_FOR_ID(ignore)
Expand Down
1 change: 0 additions & 1 deletion Include/internal/pycore_runtime_init_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Include/internal/pycore_unicodeobject_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 11 additions & 75 deletions Modules/clinic/grpmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions Modules/grpmodule.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@

/* UNIX group file access module */

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

#include "Python.h"
#include "posixmodule.h"

#include <errno.h> // ERANGE
#include <grp.h> // getgrgid_r()
#include <string.h> // memcpy()
#include <unistd.h> // sysconf()

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

#define SET(i,val) PyStructSequence_SET_ITEM(v, i, val)
#define SET(i,val) PyStructSequence_SetItem(v, i, val)
SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_name));
if (p->gr_passwd)
SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_passwd));
Expand Down
2 changes: 0 additions & 2 deletions Modules/posixmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#ifndef Py_POSIXMODULE_H
#define Py_POSIXMODULE_H
#ifndef Py_LIMITED_API
#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -34,5 +33,4 @@ extern int _Py_Sigset_Converter(PyObject *, void *);
#ifdef __cplusplus
}
#endif
#endif // !Py_LIMITED_API
#endif // !Py_POSIXMODULE_H
2 changes: 2 additions & 0 deletions Tools/c-analyzer/cpython/ignored.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -740,3 +740,5 @@ Modules/expat/xmlrole.c - error -
Modules/_io/_iomodule.c - _PyIO_Module -
Modules/_sqlite/module.c - _sqlite3module -
Modules/clinic/md5module.c.h _md5_md5 _keywords -
Modules/clinic/grpmodule.c.h grp_getgrgid _keywords -
Modules/clinic/grpmodule.c.h grp_getgrnam _keywords -

0 comments on commit 3cc5ae5

Please sign in to comment.