* Building CPython now requires a compiler with support for the C11 atomic
library, GCC built-in atomic functions, or MSVC interlocked intrinsics.
-* The ``errno``, ``md5``, ``resource``, ``winsound``, ``_ctypes_test``,
- ``_multiprocessing.posixshmem``, ``_scproxy``, ``_stat``,
+* The ``errno``, ``fcntl``, ``grp``, ``md5``, ``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>`.
(Contributed by Victor Stinner in :gh:`85283`.)
preserve
[clinic start generated code]*/
-#include "pycore_fileutils.h" // _PyLong_FileDescriptor_Converter()
-#include "pycore_modsupport.h" // _PyArg_CheckPositional()
-
PyDoc_STRVAR(fcntl_fcntl__doc__,
"fcntl($module, fd, cmd, arg=0, /)\n"
"--\n"
"corresponding to the return value of the fcntl call in the C code.");
#define FCNTL_FCNTL_METHODDEF \
- {"fcntl", _PyCFunction_CAST(fcntl_fcntl), METH_FASTCALL, fcntl_fcntl__doc__},
+ {"fcntl", (PyCFunction)(void(*)(void))fcntl_fcntl, METH_FASTCALL, fcntl_fcntl__doc__},
static PyObject *
fcntl_fcntl_impl(PyObject *module, int fd, int code, PyObject *arg);
int code;
PyObject *arg = NULL;
- if (!_PyArg_CheckPositional("fcntl", nargs, 2, 3)) {
+ if (nargs < 2) {
+ PyErr_Format(PyExc_TypeError, "fcntl expected at least 2 arguments, got %zd", nargs);
+ goto exit;
+ }
+ if (nargs > 3) {
+ PyErr_Format(PyExc_TypeError, "fcntl expected at most 3 arguments, got %zd", nargs);
goto exit;
}
- if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
+ fd = PyObject_AsFileDescriptor(args[0]);
+ if (fd < 0) {
goto exit;
}
code = PyLong_AsInt(args[1]);
"code.");
#define FCNTL_IOCTL_METHODDEF \
- {"ioctl", _PyCFunction_CAST(fcntl_ioctl), METH_FASTCALL, fcntl_ioctl__doc__},
+ {"ioctl", (PyCFunction)(void(*)(void))fcntl_ioctl, METH_FASTCALL, fcntl_ioctl__doc__},
static PyObject *
fcntl_ioctl_impl(PyObject *module, int fd, unsigned int code,
PyObject *ob_arg = NULL;
int mutate_arg = 1;
- if (!_PyArg_CheckPositional("ioctl", nargs, 2, 4)) {
+ if (nargs < 2) {
+ PyErr_Format(PyExc_TypeError, "ioctl expected at least 2 arguments, got %zd", nargs);
goto exit;
}
- if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
+ if (nargs > 4) {
+ PyErr_Format(PyExc_TypeError, "ioctl expected at most 4 arguments, got %zd", nargs);
+ goto exit;
+ }
+ fd = PyObject_AsFileDescriptor(args[0]);
+ if (fd < 0) {
goto exit;
}
code = (unsigned int)PyLong_AsUnsignedLongMask(args[1]);
"function is emulated using fcntl()).");
#define FCNTL_FLOCK_METHODDEF \
- {"flock", _PyCFunction_CAST(fcntl_flock), METH_FASTCALL, fcntl_flock__doc__},
+ {"flock", (PyCFunction)(void(*)(void))fcntl_flock, METH_FASTCALL, fcntl_flock__doc__},
static PyObject *
fcntl_flock_impl(PyObject *module, int fd, int code);
int fd;
int code;
- if (!_PyArg_CheckPositional("flock", nargs, 2, 2)) {
+ if (nargs != 2) {
+ PyErr_Format(PyExc_TypeError, "flock expected 2 arguments, got %zd", nargs);
goto exit;
}
- if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
+ fd = PyObject_AsFileDescriptor(args[0]);
+ if (fd < 0) {
goto exit;
}
code = PyLong_AsInt(args[1]);
" 2 - relative to the end of the file (SEEK_END)");
#define FCNTL_LOCKF_METHODDEF \
- {"lockf", _PyCFunction_CAST(fcntl_lockf), METH_FASTCALL, fcntl_lockf__doc__},
+ {"lockf", (PyCFunction)(void(*)(void))fcntl_lockf, METH_FASTCALL, fcntl_lockf__doc__},
static PyObject *
fcntl_lockf_impl(PyObject *module, int fd, int code, PyObject *lenobj,
PyObject *startobj = NULL;
int whence = 0;
- if (!_PyArg_CheckPositional("lockf", nargs, 2, 5)) {
+ if (nargs < 2) {
+ PyErr_Format(PyExc_TypeError, "lockf expected at least 2 arguments, got %zd", nargs);
+ goto exit;
+ }
+ if (nargs > 5) {
+ PyErr_Format(PyExc_TypeError, "lockf expected at most 5 arguments, got %zd", nargs);
goto exit;
}
- if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
+ fd = PyObject_AsFileDescriptor(args[0]);
+ if (fd < 0) {
goto exit;
}
code = PyLong_AsInt(args[1]);
exit:
return return_value;
}
-/*[clinic end generated code: output=732e33ba92042031 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=26793691ab1c75ba input=a9049054013a1b77]*/