@@ -37,22 +37,28 @@ fcntl.fcntl
3737 arg: object(c_default='NULL') = 0
3838 /
3939
40- Perform the operation `cmd` on file descriptor fd.
41-
42- The values used for `cmd` are operating system dependent, and are available
43- as constants in the fcntl module, using the same names as used in
44- the relevant C header files. The argument arg is optional, and
45- defaults to 0; it may be an int or a string. If arg is given as a string,
46- the return value of fcntl is a string of that length, containing the
47- resulting value put in the arg buffer by the operating system. The length
48- of the arg string is not allowed to exceed 1024 bytes. If the arg given
49- is an integer or if none is specified, the result value is an integer
50- corresponding to the return value of the fcntl call in the C code.
40+ Perform the operation cmd on file descriptor fd.
41+
42+ The values used for cmd are operating system dependent, and are
43+ available as constants in the fcntl module, using the same names as used
44+ in the relevant C header files. The argument arg is optional, and
45+ defaults to 0; it may be an integer, a bytes-like object or a string.
46+ If arg is given as a string, it will be encoded to binary using the
47+ UTF-8 encoding.
48+
49+ If the arg given is an integer or if none is specified, the result value
50+ is an integer corresponding to the return value of the fcntl() call in
51+ the C code.
52+
53+ If arg is given as a bytes-like object, the return value of fcntl() is a
54+ bytes object of that length, containing the resulting value put in the
55+ arg buffer by the operating system. The length of the arg buffer is not
56+ allowed to exceed 1024 bytes.
5157[clinic start generated code]*/
5258
5359static PyObject *
5460fcntl_fcntl_impl (PyObject * module , int fd , int code , PyObject * arg )
55- /*[clinic end generated code: output=888fc93b51c295bd input=7955340198e5f334 ]*/
61+ /*[clinic end generated code: output=888fc93b51c295bd input=56c6d6196a4854df ]*/
5662{
5763 unsigned int int_arg = 0 ;
5864 int ret ;
@@ -117,40 +123,40 @@ fcntl.ioctl
117123 mutate_flag as mutate_arg: bool = True
118124 /
119125
120- Perform the operation ` request` on file descriptor `fd` .
126+ Perform the operation request on file descriptor fd .
121127
122- The values used for ` request` are operating system dependent, and are available
123- as constants in the fcntl or termios library modules, using the same names as
124- used in the relevant C header files.
128+ The values used for request are operating system dependent, and are
129+ available as constants in the fcntl or termios library modules, using
130+ the same names as used in the relevant C header files.
125131
126- The argument `arg` is optional, and defaults to 0; it may be an int or a
127- buffer containing character data (most likely a string or an array).
132+ The argument arg is optional, and defaults to 0; it may be an integer, a
133+ bytes-like object or a string. If arg is given as a string, it will be
134+ encoded to binary using the UTF-8 encoding.
128135
129- If the argument is a mutable buffer (such as an array) and if the
130- mutate_flag argument (which is only allowed in this case) is true then the
131- buffer is (in effect) passed to the operating system and changes made by
132- the OS will be reflected in the contents of the buffer after the call has
133- returned. The return value is the integer returned by the ioctl system
134- call.
136+ If the arg given is an integer or if none is specified, the result value
137+ is an integer corresponding to the return value of the ioctl() call in
138+ the C code.
135139
136- If the argument is a mutable buffer and the mutable_flag argument is false,
137- the behavior is as if a string had been passed.
140+ If the argument is a mutable buffer (such as a bytearray) and the
141+ mutate_flag argument is true (default) then the buffer is (in effect)
142+ passed to the operating system and changes made by the OS will be
143+ reflected in the contents of the buffer after the call has returned.
144+ The return value is the integer returned by the ioctl() system call.
138145
139- If the argument is an immutable buffer (most likely a string) then a copy
140- of the buffer is passed to the operating system and the return value is a
141- string of the same length containing whatever the operating system put in
142- the buffer. The length of the arg buffer in this case is not allowed to
143- exceed 1024 bytes.
146+ If the argument is a mutable buffer and the mutable_flag argument is
147+ false, the behavior is as if an immutable buffer had been passed.
144148
145- If the arg given is an integer or if none is specified, the result value is
146- an integer corresponding to the return value of the ioctl call in the C
147- code.
149+ If the argument is an immutable buffer then a copy of the buffer is
150+ passed to the operating system and the return value is a bytes object of
151+ the same length containing whatever the operating system put in the
152+ buffer. The length of the arg buffer in this case is not allowed to
153+ exceed 1024 bytes.
148154[clinic start generated code]*/
149155
150156static PyObject *
151157fcntl_ioctl_impl (PyObject * module , int fd , unsigned int code ,
152158 PyObject * ob_arg , int mutate_arg )
153- /*[clinic end generated code: output=7f7f5840c65991be input=967b4a4cbeceb0a8 ]*/
159+ /*[clinic end generated code: output=7f7f5840c65991be input=e345d82d499e5273 ]*/
154160{
155161#define IOCTL_BUFSZ 1024
156162 /* We use the unsigned non-checked 'I' format for the 'code' parameter
@@ -280,15 +286,15 @@ fcntl.flock
280286 operation as code: int
281287 /
282288
283- Perform the lock operation `operation` on file descriptor `fd` .
289+ Perform the lock operation on file descriptor fd .
284290
285291See the Unix manual page for flock(2) for details (On some systems, this
286292function is emulated using fcntl()).
287293[clinic start generated code]*/
288294
289295static PyObject *
290296fcntl_flock_impl (PyObject * module , int fd , int code )
291- /*[clinic end generated code: output=84059e2b37d2fc64 input=0bfc00f795953452 ]*/
297+ /*[clinic end generated code: output=84059e2b37d2fc64 input=ade68943e8599f0a ]*/
292298{
293299 int ret ;
294300 int async_err = 0 ;
@@ -351,22 +357,22 @@ fcntl.lockf
351357
352358A wrapper around the fcntl() locking calls.
353359
354- `fd` is the file descriptor of the file to lock or unlock, and operation is one
355- of the following values:
360+ fd is the file descriptor of the file to lock or unlock, and operation
361+ is one of the following values:
356362
357363 LOCK_UN - unlock
358364 LOCK_SH - acquire a shared lock
359365 LOCK_EX - acquire an exclusive lock
360366
361367When operation is LOCK_SH or LOCK_EX, it can also be bitwise ORed with
362- LOCK_NB to avoid blocking on lock acquisition. If LOCK_NB is used and the
363- lock cannot be acquired, an OSError will be raised and the exception will
364- have an errno attribute set to EACCES or EAGAIN (depending on the operating
365- system -- for portability, check for either value).
368+ LOCK_NB to avoid blocking on lock acquisition. If LOCK_NB is used and
369+ the lock cannot be acquired, an OSError will be raised and the exception
370+ will have an errno attribute set to EACCES or EAGAIN (depending on the
371+ operating system -- for portability, check for either value).
366372
367- ` len` is the number of bytes to lock, with the default meaning to lock to
368- EOF. ` start` is the byte offset, relative to ` whence` , to that the lock
369- starts. ` whence` is as with fileobj.seek(), specifically:
373+ len is the number of bytes to lock, with the default meaning to lock to
374+ EOF. start is the byte offset, relative to whence, to that the lock
375+ starts. whence is as with fileobj.seek(), specifically:
370376
371377 0 - relative to the start of the file (SEEK_SET)
372378 1 - relative to the current buffer position (SEEK_CUR)
@@ -376,7 +382,7 @@ starts. `whence` is as with fileobj.seek(), specifically:
376382static PyObject *
377383fcntl_lockf_impl (PyObject * module , int fd , int code , PyObject * lenobj ,
378384 PyObject * startobj , int whence )
379- /*[clinic end generated code: output=4985e7a172e7461a input=5480479fc63a04b8 ]*/
385+ /*[clinic end generated code: output=4985e7a172e7461a input=369bef4d7a1c5ff4 ]*/
380386{
381387 int ret ;
382388 int async_err = 0 ;
0 commit comments