@@ -40,22 +40,27 @@ fcntl.fcntl
4040 arg: object(c_default='NULL') = 0
4141 /
4242
43- Perform the operation `cmd` on file descriptor fd.
44-
45- The values used for `cmd` are operating system dependent, and are available
46- as constants in the fcntl module, using the same names as used in
47- the relevant C header files. The argument arg is optional, and
48- defaults to 0; it may be an int or a string. If arg is given as a string,
49- the return value of fcntl is a string of that length, containing the
50- resulting value put in the arg buffer by the operating system. The length
51- of the arg string is not allowed to exceed 1024 bytes. If the arg given
52- is an integer or if none is specified, the result value is an integer
53- corresponding to the return value of the fcntl call in the C code.
43+ Perform the operation cmd on file descriptor fd.
44+
45+ The values used for cmd are operating system dependent, and are
46+ available as constants in the fcntl module, using the same names as used
47+ in the relevant C header files. The argument arg is optional, and
48+ defaults to 0; it may be an integer, a bytes-like object or a string.
49+ If arg is given as a string, it will be encoded to binary using the
50+ UTF-8 encoding.
51+
52+ If the arg given is an integer or if none is specified, the result value
53+ is an integer corresponding to the return value of the fcntl() call in
54+ the C code.
55+
56+ If arg is given as a bytes-like object, the return value of fcntl() is a
57+ bytes object of that length, containing the resulting value put in the
58+ arg buffer by the operating system.
5459[clinic start generated code]*/
5560
5661static PyObject *
5762fcntl_fcntl_impl (PyObject * module , int fd , int code , PyObject * arg )
58- /*[clinic end generated code: output=888fc93b51c295bd input=7955340198e5f334 ]*/
63+ /*[clinic end generated code: output=888fc93b51c295bd input=77340720f11665da ]*/
5964{
6065 int ret ;
6166 int async_err = 0 ;
@@ -151,7 +156,6 @@ fcntl_fcntl_impl(PyObject *module, int fd, int code, PyObject *arg)
151156
152157
153158/*[clinic input]
154- @permit_long_docstring_body
155159fcntl.ioctl
156160
157161 fd: fildes
@@ -160,40 +164,39 @@ fcntl.ioctl
160164 mutate_flag as mutate_arg: bool = True
161165 /
162166
163- Perform the operation ` request` on file descriptor `fd` .
167+ Perform the operation request on file descriptor fd .
164168
165- The values used for ` request` are operating system dependent, and are available
166- as constants in the fcntl or termios library modules, using the same names as
167- used in the relevant C header files.
169+ The values used for request are operating system dependent, and are
170+ available as constants in the fcntl or termios library modules, using
171+ the same names as used in the relevant C header files.
168172
169- The argument `arg` is optional, and defaults to 0; it may be an int or a
170- buffer containing character data (most likely a string or an array).
173+ The argument arg is optional, and defaults to 0; it may be an integer, a
174+ bytes-like object or a string. If arg is given as a string, it will be
175+ encoded to binary using the UTF-8 encoding.
171176
172- If the argument is a mutable buffer (such as an array) and if the
173- mutate_flag argument (which is only allowed in this case) is true then the
174- buffer is (in effect) passed to the operating system and changes made by
175- the OS will be reflected in the contents of the buffer after the call has
176- returned. The return value is the integer returned by the ioctl system
177- call.
177+ If the arg given is an integer or if none is specified, the result value
178+ is an integer corresponding to the return value of the ioctl() call in
179+ the C code.
178180
179- If the argument is a mutable buffer and the mutable_flag argument is false,
180- the behavior is as if a string had been passed.
181+ If the argument is a mutable buffer (such as a bytearray) and the
182+ mutate_flag argument is true (default) then the buffer is (in effect)
183+ passed to the operating system and changes made by the OS will be
184+ reflected in the contents of the buffer after the call has returned.
185+ The return value is the integer returned by the ioctl() system call.
181186
182- If the argument is an immutable buffer (most likely a string) then a copy
183- of the buffer is passed to the operating system and the return value is a
184- string of the same length containing whatever the operating system put in
185- the buffer. The length of the arg buffer in this case is not allowed to
186- exceed 1024 bytes.
187+ If the argument is a mutable buffer and the mutable_flag argument is
188+ false, the behavior is as if an immutable buffer had been passed.
187189
188- If the arg given is an integer or if none is specified, the result value is
189- an integer corresponding to the return value of the ioctl call in the C
190- code.
190+ If the argument is an immutable buffer then a copy of the buffer is
191+ passed to the operating system and the return value is a bytes object of
192+ the same length containing whatever the operating system put in the
193+ buffer.
191194[clinic start generated code]*/
192195
193196static PyObject *
194197fcntl_ioctl_impl (PyObject * module , int fd , unsigned long code , PyObject * arg ,
195198 int mutate_arg )
196- /*[clinic end generated code: output=f72baba2454d7a62 input=d7fe504d335449e2 ]*/
199+ /*[clinic end generated code: output=f72baba2454d7a62 input=954fe75c208cc492 ]*/
197200{
198201 /* We use the unsigned non-checked 'I' format for the 'code' parameter
199202 because the system expects it to be a 32bit bit field value
@@ -340,15 +343,15 @@ fcntl.flock
340343 operation as code: int
341344 /
342345
343- Perform the lock operation `operation` on file descriptor `fd` .
346+ Perform the lock operation on file descriptor fd .
344347
345348See the Unix manual page for flock(2) for details (On some systems, this
346349function is emulated using fcntl()).
347350[clinic start generated code]*/
348351
349352static PyObject *
350353fcntl_flock_impl (PyObject * module , int fd , int code )
351- /*[clinic end generated code: output=84059e2b37d2fc64 input=0bfc00f795953452 ]*/
354+ /*[clinic end generated code: output=84059e2b37d2fc64 input=ade68943e8599f0a ]*/
352355{
353356 int ret ;
354357 int async_err = 0 ;
@@ -400,7 +403,6 @@ fcntl_flock_impl(PyObject *module, int fd, int code)
400403
401404
402405/*[clinic input]
403- @permit_long_docstring_body
404406fcntl.lockf
405407
406408 fd: fildes
@@ -412,22 +414,22 @@ fcntl.lockf
412414
413415A wrapper around the fcntl() locking calls.
414416
415- `fd` is the file descriptor of the file to lock or unlock, and operation is one
416- of the following values:
417+ fd is the file descriptor of the file to lock or unlock, and operation
418+ is one of the following values:
417419
418420 LOCK_UN - unlock
419421 LOCK_SH - acquire a shared lock
420422 LOCK_EX - acquire an exclusive lock
421423
422424When operation is LOCK_SH or LOCK_EX, it can also be bitwise ORed with
423- LOCK_NB to avoid blocking on lock acquisition. If LOCK_NB is used and the
424- lock cannot be acquired, an OSError will be raised and the exception will
425- have an errno attribute set to EACCES or EAGAIN (depending on the operating
426- system -- for portability, check for either value).
425+ LOCK_NB to avoid blocking on lock acquisition. If LOCK_NB is used and
426+ the lock cannot be acquired, an OSError will be raised and the exception
427+ will have an errno attribute set to EACCES or EAGAIN (depending on the
428+ operating system -- for portability, check for either value).
427429
428- ` len` is the number of bytes to lock, with the default meaning to lock to
429- EOF. ` start` is the byte offset, relative to ` whence` , to that the lock
430- starts. ` whence` is as with fileobj.seek(), specifically:
430+ len is the number of bytes to lock, with the default meaning to lock to
431+ EOF. start is the byte offset, relative to whence, to that the lock
432+ starts. whence is as with fileobj.seek(), specifically:
431433
432434 0 - relative to the start of the file (SEEK_SET)
433435 1 - relative to the current buffer position (SEEK_CUR)
@@ -437,7 +439,7 @@ starts. `whence` is as with fileobj.seek(), specifically:
437439static PyObject *
438440fcntl_lockf_impl (PyObject * module , int fd , int code , PyObject * lenobj ,
439441 PyObject * startobj , int whence )
440- /*[clinic end generated code: output=4985e7a172e7461a input=f666662ec2edd775 ]*/
442+ /*[clinic end generated code: output=4985e7a172e7461a input=369bef4d7a1c5ff4 ]*/
441443{
442444 int ret ;
443445 int async_err = 0 ;
0 commit comments