gh-85283: Build pwd extension with the limited C API (#116841)

Argument Clinic now uses the PEP 737 "%T" format to format type name
for the limited C API.
This commit is contained in:
Victor Stinner 2024-03-15 08:49:58 +01:00 committed by GitHub
parent 41e844a4ac
commit 8fc8fbb43a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 16 additions and 12 deletions

View file

@ -2,8 +2,6 @@
preserve
[clinic start generated code]*/
#include "pycore_modsupport.h" // _PyArg_BadArgument()
PyDoc_STRVAR(pwd_getpwuid__doc__,
"getpwuid($module, uidobj, /)\n"
"--\n"
@ -36,7 +34,7 @@ pwd_getpwnam(PyObject *module, PyObject *arg)
PyObject *name;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("getpwnam", "argument", "str", arg);
PyErr_Format(PyExc_TypeError, "getpwnam() argument must be str, not %T", arg);
goto exit;
}
name = arg;
@ -73,4 +71,4 @@ pwd_getpwall(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef PWD_GETPWALL_METHODDEF
#define PWD_GETPWALL_METHODDEF
#endif /* !defined(PWD_GETPWALL_METHODDEF) */
/*[clinic end generated code: output=5a8fb12939ff4ea3 input=a9049054013a1b77]*/
/*[clinic end generated code: output=dac88d500f6d6f49 input=a9049054013a1b77]*/

View file

@ -1,9 +1,16 @@
/* UNIX password file access module */
// 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 <pwd.h> // getpwuid()
#include <unistd.h> // sysconf()
@ -83,7 +90,7 @@ mkpwent(PyObject *module, struct passwd *p)
if (item == NULL) { \
goto error; \
} \
PyStructSequence_SET_ITEM(v, setIndex++, item); \
PyStructSequence_SetItem(v, setIndex++, item); \
} while(0)
SET_STRING(p->pw_name);