Skip to content

gh-132742: Refactor fcntl.fcntl() and fcntl.ioctl() #132768

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 4 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 9 additions & 2 deletions Doc/library/fcntl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ The module defines the following functions:
for *cmd* are operating system dependent, and are available as constants
in the :mod:`fcntl` module, using the same names as used in the relevant C
header files. The argument *arg* can either be an integer value, a
:class:`bytes` object, or a string.
:term:`bytes-like object`, or a string.
The type and size of *arg* must match the type and size of
the argument of the operation as specified in the relevant C documentation.

When *arg* is an integer, the function returns the integer
return value of the C :c:func:`fcntl` call.

When the argument is bytes, it represents a binary structure,
When the argument is bytes-like object, it represents a binary structure,
for example, created by :func:`struct.pack`.
A string value is encoded to binary using the UTF-8 encoding.
The binary data is copied to a buffer whose address is
Expand All @@ -117,6 +117,10 @@ The module defines the following functions:

.. audit-event:: fcntl.fcntl fd,cmd,arg fcntl.fcntl

.. versionchanged:: next
Add support of arbitrary :term:`bytes-like objects <bytes-like object>`,
not only :class:`bytes`.


.. function:: ioctl(fd, request, arg=0, mutate_flag=True, /)

Expand Down Expand Up @@ -173,6 +177,9 @@ The module defines the following functions:

.. audit-event:: fcntl.ioctl fd,request,arg fcntl.ioctl

.. versionchanged:: next
The GIL is always released during a system call.
System calls failing with EINTR are automatically retried.

.. function:: flock(fd, operation, /)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:func:`fcntl.fcntl` now supports arbitrary :term:`bytes-like objects
<bytes-like object>`, not only :class:`bytes`. :func:`fcntl.ioctl` now
automatically retries system calls failing with EINTR and releases the GIL
during a system call even for large bytes-like object.
12 changes: 6 additions & 6 deletions Modules/clinic/fcntlmodule.c.h

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

Loading
Loading