FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-101819: Adapt _io.IOBase.seek and _io.IOBase.truncate to Argument Clinic by erlend-aasland · Pull Request #104384 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .h  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
102 changes: 101 additions & 1 deletion Modules/_io/clinic/iobase.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 34 additions & 21 deletions Modules/_io/iobase.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,27 @@ iobase_unsupported(_PyIO_State *state, const char *message)

/* Positioning */

PyDoc_STRVAR(iobase_seek_doc,
"Change stream position.\n"
"\n"
"Change the stream position to the given byte offset. The offset is\n"
"interpreted relative to the position indicated by whence. Values\n"
"for whence are:\n"
"\n"
"* 0 -- start of stream (the default); offset should be zero or positive\n"
"* 1 -- current stream position; offset may be negative\n"
"* 2 -- end of stream; offset is usually negative\n"
"\n"
"Return the new absolute position.");
/*[clinic input]
Comment thread
erlend-aasland marked this conversation as resolved.
_io._IOBase.seek
cls: defining_class
/
*args: object

Change the stream position to the given byte offset.

The offset is interpreted relative to the position indicated by whence.
Values for whence are:

* 0 -- start of stream (the default); offset should be zero or positive
* 1 -- current stream position; offset may be negative
* 2 -- end of stream; offset is usually negative

Return the new absolute position.
[clinic start generated code]*/

static PyObject *
iobase_seek(PyObject *self, PyObject *args)
_io__IOBase_seek_impl(PyObject *self, PyTypeObject *cls, PyObject *args)
/*[clinic end generated code: output=1dd694ac9de260fa input=ebb5476eb22fc5d4]*/
{
_PyIO_State *state = IO_STATE();
return iobase_unsupported(state, "seek");
Expand All @@ -112,14 +118,21 @@ _io__IOBase_tell_impl(PyObject *self)
return _PyObject_CallMethod(self, &_Py_ID(seek), "ii", 0, 1);
}

PyDoc_STRVAR(iobase_truncate_doc,
"Truncate file to size bytes.\n"
"\n"
"File pointer is left unchanged. Size defaults to the current IO\n"
"position as reported by tell(). Returns the new size.");
/*[clinic input]
_io._IOBase.truncate
cls: defining_class
/
*args: object

Truncate file to size bytes.

File pointer is left unchanged. Size defaults to the current IO position
as reported by tell(). Return the new size.
[clinic start generated code]*/

static PyObject *
iobase_truncate(PyObject *self, PyObject *args)
_io__IOBase_truncate_impl(PyObject *self, PyTypeObject *cls, PyObject *args)
/*[clinic end generated code: output=b7eed4649cbe22c1 input=ad90582a1d8b5cc9]*/
{
_PyIO_State *state = IO_STATE();
return iobase_unsupported(state, "truncate");
Expand Down Expand Up @@ -809,9 +822,9 @@ _io__IOBase_writelines(PyObject *self, PyObject *lines)
#include "clinic/iobase.c.h"

static PyMethodDef iobase_methods[] = {
{"seek", iobase_seek, METH_VARARGS, iobase_seek_doc},
_IO__IOBASE_SEEK_METHODDEF
_IO__IOBASE_TELL_METHODDEF
{"truncate", iobase_truncate, METH_VARARGS, iobase_truncate_doc},
_IO__IOBASE_TRUNCATE_METHODDEF
_IO__IOBASE_FLUSH_METHODDEF
_IO__IOBASE_CLOSE_METHODDEF

Expand Down

Back | FazBrowse Home | New Git URL