* Building CPython now requires a compiler with support for the C11 atomic
library, GCC built-in atomic functions, or MSVC interlocked intrinsics.
-* The ``errno``, ``fcntl``, ``grp``, ``md5``, ``resource``, ``winsound``,
+* The ``errno``, ``fcntl``, ``grp``, ``md5``, ``pwd``, ``resource``, ``winsound``,
``_ctypes_test``, ``_multiprocessing.posixshmem``, ``_scproxy``, ``_stat``,
``_testimportmultiple`` and ``_uuid`` C extensions are now built with the
:ref:`limited C API <limited-c-api>`.
-The ``fcntl`` and ``grp`` C extensions are now built with the :ref:`limited
+The ``fcntl``, ``grp`` and ``pwd`` C extensions are now built with the :ref:`limited
C API <limited-c-api>`. (Contributed by Victor Stinner in :gh:`85283`.)
preserve
[clinic start generated code]*/
-#include "pycore_modsupport.h" // _PyArg_BadArgument()
-
PyDoc_STRVAR(pwd_getpwuid__doc__,
"getpwuid($module, uidobj, /)\n"
"--\n"
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;
#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]*/
/* 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()
if (item == NULL) { \
goto error; \
} \
- PyStructSequence_SET_ITEM(v, setIndex++, item); \
+ PyStructSequence_SetItem(v, setIndex++, item); \
} while(0)
SET_STRING(p->pw_name);
if limited_capi:
if expected_literal:
return (f'PyErr_Format(PyExc_TypeError, '
- f'"{{{{name}}}}() {displayname} must be {expected}, not %.50s", '
- f'{{argname}} == Py_None ? "None" : Py_TYPE({{argname}})->tp_name);')
+ f'"{{{{name}}}}() {displayname} must be {expected}, not %T", '
+ f'{{argname}});')
else:
return (f'PyErr_Format(PyExc_TypeError, '
- f'"{{{{name}}}}() {displayname} must be %.50s, not %.50s", '
- f'"{expected}", '
- f'{{argname}} == Py_None ? "None" : Py_TYPE({{argname}})->tp_name);')
+ f'"{{{{name}}}}() {displayname} must be %s, not %T", '
+ f'"{expected}", {{argname}});')
else:
if expected_literal:
expected = f'"{expected}"'