Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e629ab6

Browse filesBrowse files
gh-101819: Adapt _io.IOBase.seek and _io.IOBase.truncate to Argument Clinic (#104384)
1 parent ed41124 commit e629ab6
Copy full SHA for e629ab6

File tree

2 files changed

+135
-22
lines changed
Filter options

2 files changed

+135
-22
lines changed

‎Modules/_io/clinic/iobase.c.h

Copy file name to clipboardExpand all lines: Modules/_io/clinic/iobase.c.h
+101-1Lines changed: 101 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Modules/_io/iobase.c

Copy file name to clipboardExpand all lines: Modules/_io/iobase.c
+34-21Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,27 @@ iobase_unsupported(_PyIO_State *state, const char *message)
7979

8080
/* Positioning */
8181

82-
PyDoc_STRVAR(iobase_seek_doc,
83-
"Change stream position.\n"
84-
"\n"
85-
"Change the stream position to the given byte offset. The offset is\n"
86-
"interpreted relative to the position indicated by whence. Values\n"
87-
"for whence are:\n"
88-
"\n"
89-
"* 0 -- start of stream (the default); offset should be zero or positive\n"
90-
"* 1 -- current stream position; offset may be negative\n"
91-
"* 2 -- end of stream; offset is usually negative\n"
92-
"\n"
93-
"Return the new absolute position.");
82+
/*[clinic input]
83+
_io._IOBase.seek
84+
cls: defining_class
85+
/
86+
*args: object
87+
88+
Change the stream position to the given byte offset.
89+
90+
The offset is interpreted relative to the position indicated by whence.
91+
Values for whence are:
92+
93+
* 0 -- start of stream (the default); offset should be zero or positive
94+
* 1 -- current stream position; offset may be negative
95+
* 2 -- end of stream; offset is usually negative
96+
97+
Return the new absolute position.
98+
[clinic start generated code]*/
9499

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

115-
PyDoc_STRVAR(iobase_truncate_doc,
116-
"Truncate file to size bytes.\n"
117-
"\n"
118-
"File pointer is left unchanged. Size defaults to the current IO\n"
119-
"position as reported by tell(). Returns the new size.");
121+
/*[clinic input]
122+
_io._IOBase.truncate
123+
cls: defining_class
124+
/
125+
*args: object
126+
127+
Truncate file to size bytes.
128+
129+
File pointer is left unchanged. Size defaults to the current IO position
130+
as reported by tell(). Return the new size.
131+
[clinic start generated code]*/
120132

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

811824
static PyMethodDef iobase_methods[] = {
812-
{"seek", iobase_seek, METH_VARARGS, iobase_seek_doc},
825+
_IO__IOBASE_SEEK_METHODDEF
813826
_IO__IOBASE_TELL_METHODDEF
814-
{"truncate", iobase_truncate, METH_VARARGS, iobase_truncate_doc},
827+
_IO__IOBASE_TRUNCATE_METHODDEF
815828
_IO__IOBASE_FLUSH_METHODDEF
816829
_IO__IOBASE_CLOSE_METHODDEF
817830

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.