-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-132742: Update documentation for the fcntl module #132765
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
Changes from 1 commit
07b081d
a35188d
a8f1537
a4e24f4
ebbfe6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -89,20 +89,32 @@ 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, or a | ||||||||||||||||||||||||
| :class:`bytes` object. With an integer value, the return value of this | ||||||||||||||||||||||||
| function is the integer return value of the C :c:func:`fcntl` call. When | ||||||||||||||||||||||||
| the argument is bytes it represents a binary structure, e.g. created by | ||||||||||||||||||||||||
| :func:`struct.pack`. The binary data is copied to a buffer whose address is | ||||||||||||||||||||||||
| :class:`bytes` object, or a string. | ||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like it accepts any readable buffer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may accept other buffers without |
||||||||||||||||||||||||
| The type and the size of *arg* must match the type and the size of | ||||||||||||||||||||||||
serhiy-storchaka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||
| the argument of the operation as specified in the relevant C documentation. | ||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Link? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Depending on platform. Various manpages on Posix systems, some Microsoft links on Windows. |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| With an integer value, the return value of this function is the integer | ||||||||||||||||||||||||
| return value of the C :c:func:`fcntl` call. | ||||||||||||||||||||||||
serhiy-storchaka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| When the argument is bytes, it represents a binary structure, | ||||||||||||||||||||||||
| e.g. created by :func:`struct.pack`. | ||||||||||||||||||||||||
serhiy-storchaka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||
| A string value is encoded to binary using the UTF-8 encoding. | ||||||||||||||||||||||||
| The binary data is copied to a buffer whose address is | ||||||||||||||||||||||||
| passed to the C :c:func:`fcntl` call. The return value after a successful | ||||||||||||||||||||||||
| call is the contents of the buffer, converted to a :class:`bytes` object. | ||||||||||||||||||||||||
| The length of the returned object will be the same as the length of the | ||||||||||||||||||||||||
| *arg* argument. This is limited to 1024 bytes. If the information returned | ||||||||||||||||||||||||
| in the buffer by the operating system is larger than 1024 bytes, this is | ||||||||||||||||||||||||
| most likely to result in a segmentation violation or a more subtle data | ||||||||||||||||||||||||
| corruption. | ||||||||||||||||||||||||
| *arg* argument. This is limited to 1024 bytes. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| If the :c:func:`fcntl` call fails, an :exc:`OSError` is raised. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| .. note:: | ||||||||||||||||||||||||
| If the type or the size of *arg* does not match the type or the size | ||||||||||||||||||||||||
serhiy-storchaka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||
| of the argument of the operation (for example, if an integer is | ||||||||||||||||||||||||
| passed when a pointer is expected, or the information returned in | ||||||||||||||||||||||||
| the buffer by the operating system is larger than 1024 bytes), | ||||||||||||||||||||||||
| this is most likely to result in a segmentation violation or | ||||||||||||||||||||||||
| a more subtle data corruption. | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| If the type or the size of *arg* does not match the type or the size | |
| of the argument of the operation (for example, if an integer is | |
| passed when a pointer is expected, or the information returned in | |
| the buffer by the operating system is larger than 1024 bytes), | |
| this is most likely to result in a segmentation violation or | |
| a more subtle data corruption. | |
| If the type or size of *arg* does not match that of the operation's argument | |
| (for example, if an integer is passed when a pointer is expected, or the | |
| information returned in the buffer by the operating system is larger | |
| than 1024 bytes), it will most likely result in a segmentation violation or | |
| more subtle data corruption. |
Slight rewording suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was mainly the moved old documentation.
serhiy-storchaka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
serhiy-storchaka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
serhiy-storchaka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking the same thing, but since most fcntl values are platform-dependent there probably isn't a good documentation link to use here.
serhiy-storchaka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was incorrect, the 1024 byte limit is not avoided if mutate_flag is false.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the C documentation, the type is int or a pointer to specific structure. The Python argument must be int or a bytes-like object of the corresponding size.
serhiy-storchaka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
serhiy-storchaka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| this is most likely to result in a segmentation violation or | |
| a more subtle data corruption. | |
| it is most likely to result in a segmentation violation or | |
| a more subtle data corruption. |
Continues on from previous suggestion
Uh oh!
There was an error while loading. Please reload this page.