mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
- name the last parameter *whence*, like it is for seek() methods on
file objects
- add param docstrings
- structure the valid *whence* params
(cherry picked from commit dd4442c8f5
)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
parent
2807430657
commit
41634edb2b
3 changed files with 33 additions and 14 deletions
|
@ -1163,17 +1163,22 @@ as internal buffering of data.
|
||||||
.. versionadded:: 3.11
|
.. versionadded:: 3.11
|
||||||
|
|
||||||
|
|
||||||
.. function:: lseek(fd, pos, how, /)
|
.. function:: lseek(fd, pos, whence, /)
|
||||||
|
|
||||||
Set the current position of file descriptor *fd* to position *pos*, modified
|
Set the current position of file descriptor *fd* to position *pos*, modified
|
||||||
by *how*: :const:`SEEK_SET` or ``0`` to set the position relative to the
|
by *whence*, and return the new position in bytes relative to
|
||||||
beginning of the file; :const:`SEEK_CUR` or ``1`` to set it relative to the
|
the start of the file.
|
||||||
current position; :const:`SEEK_END` or ``2`` to set it relative to the end of
|
Valid values for *whence* are:
|
||||||
the file. Return the new cursor position in bytes, starting from the beginning.
|
|
||||||
|
* :const:`SEEK_SET` or ``0`` -- set *pos* relative to the beginning of the file
|
||||||
|
* :const:`SEEK_CUR` or ``1`` -- set *pos* relative to the current file position
|
||||||
|
* :const:`SEEK_END` or ``2`` -- set *pos* relative to the end of the file
|
||||||
|
* :const:`SEEK_HOLE` -- set *pos* to the next data location, relative to *pos*
|
||||||
|
* :const:`SEEK_DATA` -- set *pos* to the next data hole, relative to *pos*
|
||||||
|
|
||||||
.. versionchanged:: 3.3
|
.. versionchanged:: 3.3
|
||||||
|
|
||||||
Add support for :const:`SEEK_HOLE` and :const:`SEEK_DATA`.
|
Add support for :const:`!SEEK_HOLE` and :const:`!SEEK_DATA`.
|
||||||
|
|
||||||
|
|
||||||
.. data:: SEEK_SET
|
.. data:: SEEK_SET
|
||||||
|
|
17
Modules/clinic/posixmodule.c.h
generated
17
Modules/clinic/posixmodule.c.h
generated
|
@ -6496,13 +6496,22 @@ exit:
|
||||||
#endif /* defined(HAVE_LOCKF) */
|
#endif /* defined(HAVE_LOCKF) */
|
||||||
|
|
||||||
PyDoc_STRVAR(os_lseek__doc__,
|
PyDoc_STRVAR(os_lseek__doc__,
|
||||||
"lseek($module, fd, position, how, /)\n"
|
"lseek($module, fd, position, whence, /)\n"
|
||||||
"--\n"
|
"--\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Set the position of a file descriptor. Return the new position.\n"
|
"Set the position of a file descriptor. Return the new position.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Return the new cursor position in number of bytes\n"
|
" fd\n"
|
||||||
"relative to the beginning of the file.");
|
" An open file descriptor, as returned by os.open().\n"
|
||||||
|
" position\n"
|
||||||
|
" Position, interpreted relative to \'whence\'.\n"
|
||||||
|
" whence\n"
|
||||||
|
" The relative position to seek from. Valid values are:\n"
|
||||||
|
" - SEEK_SET: seek from the start of the file.\n"
|
||||||
|
" - SEEK_CUR: seek from the current file position.\n"
|
||||||
|
" - SEEK_END: seek from the end of the file.\n"
|
||||||
|
"\n"
|
||||||
|
"The return value is the number of bytes relative to the beginning of the file.");
|
||||||
|
|
||||||
#define OS_LSEEK_METHODDEF \
|
#define OS_LSEEK_METHODDEF \
|
||||||
{"lseek", _PyCFunction_CAST(os_lseek), METH_FASTCALL, os_lseek__doc__},
|
{"lseek", _PyCFunction_CAST(os_lseek), METH_FASTCALL, os_lseek__doc__},
|
||||||
|
@ -11990,4 +11999,4 @@ exit:
|
||||||
#ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF
|
#ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF
|
||||||
#define OS_WAITSTATUS_TO_EXITCODE_METHODDEF
|
#define OS_WAITSTATUS_TO_EXITCODE_METHODDEF
|
||||||
#endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */
|
#endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */
|
||||||
/*[clinic end generated code: output=9d8b0d6717c9af54 input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=6646be70849f971f input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -10421,19 +10421,24 @@ os_lockf_impl(PyObject *module, int fd, int command, Py_off_t length)
|
||||||
os.lseek -> Py_off_t
|
os.lseek -> Py_off_t
|
||||||
|
|
||||||
fd: int
|
fd: int
|
||||||
|
An open file descriptor, as returned by os.open().
|
||||||
position: Py_off_t
|
position: Py_off_t
|
||||||
how: int
|
Position, interpreted relative to 'whence'.
|
||||||
|
whence as how: int
|
||||||
|
The relative position to seek from. Valid values are:
|
||||||
|
- SEEK_SET: seek from the start of the file.
|
||||||
|
- SEEK_CUR: seek from the current file position.
|
||||||
|
- SEEK_END: seek from the end of the file.
|
||||||
/
|
/
|
||||||
|
|
||||||
Set the position of a file descriptor. Return the new position.
|
Set the position of a file descriptor. Return the new position.
|
||||||
|
|
||||||
Return the new cursor position in number of bytes
|
The return value is the number of bytes relative to the beginning of the file.
|
||||||
relative to the beginning of the file.
|
|
||||||
[clinic start generated code]*/
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static Py_off_t
|
static Py_off_t
|
||||||
os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how)
|
os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how)
|
||||||
/*[clinic end generated code: output=971e1efb6b30bd2f input=902654ad3f96a6d3]*/
|
/*[clinic end generated code: output=971e1efb6b30bd2f input=f096e754c5367504]*/
|
||||||
{
|
{
|
||||||
Py_off_t result;
|
Py_off_t result;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue