Skip to content

Commit ec30275

Browse files
gh-132742: Refactor fcntl.fcntl() and fcntl.ioctl()
1 parent 5f50541 commit ec30275

File tree

4 files changed

+144
-135
lines changed

4 files changed

+144
-135
lines changed

Doc/library/fcntl.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ The module defines the following functions:
8989
for *cmd* are operating system dependent, and are available as constants
9090
in the :mod:`fcntl` module, using the same names as used in the relevant C
9191
header files. The argument *arg* can either be an integer value, a
92-
:class:`bytes` object, or a string.
92+
:term:`bytes-like object`, or a string.
9393
The type and size of *arg* must match the type and size of
9494
the argument of the operation as specified in the relevant C documentation.
9595

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

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

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

120+
.. versionchanged:: next
121+
Add support of arbitrary :term:`bytes-like objects <bytes-like object>`,
122+
not only :class:`bytes`.
123+
120124

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

@@ -173,6 +177,9 @@ The module defines the following functions:
173177

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

180+
.. versionchanged:: next
181+
The GIL is always released during a system call.
182+
System calls failing with EINTR are automatically retries.
176183

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:func:`fcntl.fcntl` now supports arbitrary :term:`bytes-like objects
2+
<bytes-like object>`, not only :class:`bytes`. :func:`fcntl.ioctl` now
3+
automatically retries system calls failing with EINTR and releases the GIL
4+
during a system call even for large bytes-like object.

Modules/clinic/fcntlmodule.c.h

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)