8000 gh-85283: Convert grp extension to the limited C API by vstinner · Pull Request #116611 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-85283: Convert grp extension to the limited C API #116611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-85283: Convert grp extension to the limited C API
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 11, 2024
commit 7d82128363f89c991accb2aa175e4a7e5b63967a
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
0