@@ -41,22 +41,28 @@ fcntl.fcntl
4141 arg: object(c_default='NULL') = 0
4242 /
4343
44- Perform the operation `cmd` on file descriptor fd.
45-
46- The values used for `cmd` are operating system dependent, and are available
47- as constants in the fcntl module, using the same names as used in
48- the relevant C header files. The argument arg is optional, and
49- defaults to 0; it may be an int or a string. If arg is given as a string,
50- the return value of fcntl is a string of that length, containing the
51- resulting value put in the arg buffer by the operating system. The length
52- of the arg string is not allowed to exceed 1024 bytes. If the arg given
53- is an integer or if none is specified, the result value is an integer
54- corresponding to the return value of the fcntl call in the C code.
44+ Perform the operation cmd on file descriptor fd.
45+
46+ The values used for cmd are operating system dependent, and are
47+ available as constants in the fcntl module, using the same names as used
48+ in the relevant C header files. The argument arg is optional, and
49+ defaults to 0; it may be an integer, a bytes-like object or a string.
50+ If arg is given as a string, it will be encoded to binary using the
51+ UTF-8 encoding.
52+
53+ If the arg given is an integer or if none is specified, the result value
54+ is an integer corresponding to the return value of the fcntl() call in
55+ the C code.
56+
57+ If arg is given as a bytes-like object, the return value of fcntl() is a
58+ bytes object of that length, containing the resulting value put in the
59+ arg buffer by the operating system. The length of the arg buffer is not
60+ allowed to exceed 1024 bytes.
5561[clinic start generated code]*/
5662
5763static PyObject *
5864fcntl_fcntl_impl (PyObject * module , int fd , int code , PyObject * arg )
59- /*[clinic end generated code: output=888fc93b51c295bd input=7955340198e5f334 ]*/
65+ /*[clinic end generated code: output=888fc93b51c295bd input=56c6d6196a4854df ]*/
6066{
6167 int ret ;
6268 int async_err = 0 ;
@@ -135,40 +141,40 @@ fcntl.ioctl
135141 mutate_flag as mutate_arg: bool = True
136142 /
137143
138- Perform the operation ` request` on file descriptor `fd` .
144+ Perform the operation request on file descriptor fd .
139145
140- The values used for ` request` are operating system dependent, and are available
141- as constants in the fcntl or termios library modules, using the same names as
142- used in the relevant C header files.
146+ The values used for request are operating system dependent, and are
147+ available as constants in the fcntl or termios library modules, using
148+ the same names as used in the relevant C header files.
143149
144- The argument `arg` is optional, and defaults to 0; it may be an int or a
145- buffer containing character data (most likely a string or an array).
150+ The argument arg is optional, and defaults to 0; it may be an integer, a
151+ bytes-like object or a string. If arg is given as a string, it will be
152+ encoded to binary using the UTF-8 encoding.
146153
147- If the argument is a mutable buffer (such as an array) and if the
148- mutate_flag argument (which is only allowed in this case) is true then the
149- buffer is (in effect) passed to the operating system and changes made by
150- the OS will be reflected in the contents of the buffer after the call has
151- returned. The return value is the integer returned by the ioctl system
152- call.
154+ If the arg given is an integer or if none is specified, the result value
155+ is an integer corresponding to the return value of the ioctl() call in
156+ the C code.
153157
154- If the argument is a mutable buffer and the mutable_flag argument is false,
155- the behavior is as if a string had been passed.
158+ If the argument is a mutable buffer (such as a bytearray) and the
159+ mutate_flag argument is true (default) then the buffer is (in effect)
160+ passed to the operating system and changes made by the OS will be
161+ reflected in the contents of the buffer after the call has returned.
162+ The return value is the integer returned by the ioctl() system call.
156163
157- If the argument is an immutable buffer (most likely a string) then a copy
158- of the buffer is passed to the operating system and the return value is a
159- string of the same length containing whatever the operating system put in
160- the buffer. The length of the arg buffer in this case is not allowed to
161- exceed 1024 bytes.
164+ If the argument is a mutable buffer and the mutable_flag argument is
165+ false, the behavior is as if an immutable buffer had been passed.
162166
163- If the arg given is an integer or if none is specified, the result value is
164- an integer corresponding to the return value of the ioctl call in the C
165- code.
167+ If the argument is an immutable buffer then a copy of the buffer is
168+ passed to the operating system and the return value is a bytes object of
169+ the same length containing whatever the operating system put in the
170+ buffer. The length of the arg buffer in this case is not allowed to
171+ exceed 1024 bytes.
166172[clinic start generated code]*/
167173
168174static PyObject *
169175fcntl_ioctl_impl (PyObject * module , int fd , unsigned long code , PyObject * arg ,
170176 int mutate_arg )
171- /*[clinic end generated code: output=f72baba2454d7a62 input=9c6cca5e2c339622 ]*/
177+ /*[clinic end generated code: output=f72baba2454d7a62 input=b69717a5588e086e ]*/
172178{
173179 /* We use the unsigned non-checked 'I' format for the 'code' parameter
174180 because the system expects it to be a 32bit bit field value
@@ -290,15 +296,15 @@ fcntl.flock
290296 operation as code: int
291297 /
292298
293- Perform the lock operation `operation` on file descriptor `fd` .
299+ Perform the lock operation on file descriptor fd .
294300
295301See the Unix manual page for flock(2) for details (On some systems, this
296302function is emulated using fcntl()).
297303[clinic start generated code]*/
298304
299305static PyObject *
300306fcntl_flock_impl (PyObject * module , int fd , int code )
301- /*[clinic end generated code: output=84059e2b37d2fc64 input=0bfc00f795953452 ]*/
307+ /*[clinic end generated code: output=84059e2b37d2fc64 input=ade68943e8599f0a ]*/
302308{
303309 int ret ;
304310 int async_err = 0 ;
@@ -361,22 +367,22 @@ fcntl.lockf
361367
362368A wrapper around the fcntl() locking calls.
363369
364- `fd` is the file descriptor of the file to lock or unlock, and operation is one
365- of the following values:
370+ fd is the file descriptor of the file to lock or unlock, and operation
371+ is one of the following values:
366372
367373 LOCK_UN - unlock
368374 LOCK_SH - acquire a shared lock
369375 LOCK_EX - acquire an exclusive lock
370376
371377When operation is LOCK_SH or LOCK_EX, it can also be bitwise ORed with
372- LOCK_NB to avoid blocking on lock acquisition. If LOCK_NB is used and the
373- lock cannot be acquired, an OSError will be raised and the exception will
374- have an errno attribute set to EACCES or EAGAIN (depending on the operating
375- system -- for portability, check for either value).
378+ LOCK_NB to avoid blocking on lock acquisition. If LOCK_NB is used and
379+ the lock cannot be acquired, an OSError will be raised and the exception
380+ will have an errno attribute set to EACCES or EAGAIN (depending on the
381+ operating system -- for portability, check for either value).
376382
377- ` len` is the number of bytes to lock, with the default meaning to lock to
378- EOF. ` start` is the byte offset, relative to ` whence` , to that the lock
379- starts. ` whence` is as with fileobj.seek(), specifically:
383+ len is the number of bytes to lock, with the default meaning to lock to
384+ EOF. start is the byte offset, relative to whence, to that the lock
385+ starts. whence is as with fileobj.seek(), specifically:
380386
381387 0 - relative to the start of the file (SEEK_SET)
382388 1 - relative to the current buffer position (SEEK_CUR)
@@ -386,7 +392,7 @@ starts. `whence` is as with fileobj.seek(), specifically:
386392static PyObject *
387393fcntl_lockf_impl (PyObject * module , int fd , int code , PyObject * lenobj ,
388394 PyObject * startobj , int whence )
389- /*[clinic end generated code: output=4985e7a172e7461a input=5480479fc63a04b8 ]*/
395+ /*[clinic end generated code: output=4985e7a172e7461a input=369bef4d7a1c5ff4 ]*/
390396{
391397 int ret ;
392398 int async_err = 0 ;
0 commit comments