python-3.6.zip added from Github

README.cosmo contains the necessary links.
This commit is contained in:
ahgamut 2021-08-08 09:38:33 +05:30 committed by Justine Tunney
parent 75fc601ff5
commit 0c4c56ff39
4219 changed files with 1968626 additions and 0 deletions

View file

@ -0,0 +1,804 @@
/*
An implementation of the new I/O lib as defined by PEP 3116 - "New I/O"
Classes defined here: UnsupportedOperation, BlockingIOError.
Functions defined here: open().
Mostly written by Amaury Forgeot d'Arc
*/
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#include "_iomodule.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif /* HAVE_SYS_STAT_H */
#ifdef MS_WINDOWS
#include <consoleapi.h>
#endif
/* Various interned strings */
PyObject *_PyIO_str_close;
PyObject *_PyIO_str_closed;
PyObject *_PyIO_str_decode;
PyObject *_PyIO_str_encode;
PyObject *_PyIO_str_fileno;
PyObject *_PyIO_str_flush;
PyObject *_PyIO_str_getstate;
PyObject *_PyIO_str_isatty;
PyObject *_PyIO_str_newlines;
PyObject *_PyIO_str_nl;
PyObject *_PyIO_str_read;
PyObject *_PyIO_str_read1;
PyObject *_PyIO_str_readable;
PyObject *_PyIO_str_readall;
PyObject *_PyIO_str_readinto;
PyObject *_PyIO_str_readline;
PyObject *_PyIO_str_reset;
PyObject *_PyIO_str_seek;
PyObject *_PyIO_str_seekable;
PyObject *_PyIO_str_setstate;
PyObject *_PyIO_str_tell;
PyObject *_PyIO_str_truncate;
PyObject *_PyIO_str_writable;
PyObject *_PyIO_str_write;
PyObject *_PyIO_empty_str;
PyObject *_PyIO_empty_bytes;
PyObject *_PyIO_zero;
PyDoc_STRVAR(module_doc,
"The io module provides the Python interfaces to stream handling. The\n"
"builtin open function is defined in this module.\n"
"\n"
"At the top of the I/O hierarchy is the abstract base class IOBase. It\n"
"defines the basic interface to a stream. Note, however, that there is no\n"
"separation between reading and writing to streams; implementations are\n"
"allowed to raise an IOError if they do not support a given operation.\n"
"\n"
"Extending IOBase is RawIOBase which deals simply with the reading and\n"
"writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide\n"
"an interface to OS files.\n"
"\n"
"BufferedIOBase deals with buffering on a raw byte stream (RawIOBase). Its\n"
"subclasses, BufferedWriter, BufferedReader, and BufferedRWPair buffer\n"
"streams that are readable, writable, and both respectively.\n"
"BufferedRandom provides a buffered interface to random access\n"
"streams. BytesIO is a simple stream of in-memory bytes.\n"
"\n"
"Another IOBase subclass, TextIOBase, deals with the encoding and decoding\n"
"of streams into text. TextIOWrapper, which extends it, is a buffered text\n"
"interface to a buffered raw stream (`BufferedIOBase`). Finally, StringIO\n"
"is an in-memory stream for text.\n"
"\n"
"Argument names are not part of the specification, and only the arguments\n"
"of open() are intended to be used as keyword arguments.\n"
"\n"
"data:\n"
"\n"
"DEFAULT_BUFFER_SIZE\n"
"\n"
" An int containing the default buffer size used by the module's buffered\n"
" I/O classes. open() uses the file's blksize (as obtained by os.stat) if\n"
" possible.\n"
);
/*
* The main open() function
*/
/*[clinic input]
module _io
_io.open
file: object
mode: str = "r"
buffering: int = -1
encoding: str(accept={str, NoneType}) = NULL
errors: str(accept={str, NoneType}) = NULL
newline: str(accept={str, NoneType}) = NULL
closefd: int(c_default="1") = True
opener: object = None
Open file and return a stream. Raise IOError upon failure.
file is either a text or byte string giving the name (and the path
if the file isn't in the current working directory) of the file to
be opened or an integer file descriptor of the file to be
wrapped. (If a file descriptor is given, it is closed when the
returned I/O object is closed, unless closefd is set to False.)
mode is an optional string that specifies the mode in which the file
is opened. It defaults to 'r' which means open for reading in text
mode. Other common values are 'w' for writing (truncating the file if
it already exists), 'x' for creating and writing to a new file, and
'a' for appending (which on some Unix systems, means that all writes
append to the end of the file regardless of the current seek position).
In text mode, if encoding is not specified the encoding used is platform
dependent: locale.getpreferredencoding(False) is called to get the
current locale encoding. (For reading and writing raw bytes use binary
mode and leave encoding unspecified.) The available modes are:
========= ===============================================================
Character Meaning
--------- ---------------------------------------------------------------
'r' open for reading (default)
'w' open for writing, truncating the file first
'x' create a new file and open it for writing
'a' open for writing, appending to the end of the file if it exists
'b' binary mode
't' text mode (default)
'+' open a disk file for updating (reading and writing)
'U' universal newline mode (deprecated)
========= ===============================================================
The default mode is 'rt' (open for reading text). For binary random
access, the mode 'w+b' opens and truncates the file to 0 bytes, while
'r+b' opens the file without truncation. The 'x' mode implies 'w' and
raises an `FileExistsError` if the file already exists.
Python distinguishes between files opened in binary and text modes,
even when the underlying operating system doesn't. Files opened in
binary mode (appending 'b' to the mode argument) return contents as
bytes objects without any decoding. In text mode (the default, or when
't' is appended to the mode argument), the contents of the file are
returned as strings, the bytes having been first decoded using a
platform-dependent encoding or using the specified encoding if given.
'U' mode is deprecated and will raise an exception in future versions
of Python. It has no effect in Python 3. Use newline to control
universal newlines mode.
buffering is an optional integer used to set the buffering policy.
Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
line buffering (only usable in text mode), and an integer > 1 to indicate
the size of a fixed-size chunk buffer. When no buffering argument is
given, the default buffering policy works as follows:
* Binary files are buffered in fixed-size chunks; the size of the buffer
is chosen using a heuristic trying to determine the underlying device's
"block size" and falling back on `io.DEFAULT_BUFFER_SIZE`.
On many systems, the buffer will typically be 4096 or 8192 bytes long.
* "Interactive" text files (files for which isatty() returns True)
use line buffering. Other text files use the policy described above
for binary files.
encoding is the name of the encoding used to decode or encode the
file. This should only be used in text mode. The default encoding is
platform dependent, but any encoding supported by Python can be
passed. See the codecs module for the list of supported encodings.
errors is an optional string that specifies how encoding errors are to
be handled---this argument should not be used in binary mode. Pass
'strict' to raise a ValueError exception if there is an encoding error
(the default of None has the same effect), or pass 'ignore' to ignore
errors. (Note that ignoring encoding errors can lead to data loss.)
See the documentation for codecs.register or run 'help(codecs.Codec)'
for a list of the permitted encoding error strings.
newline controls how universal newlines works (it only applies to text
mode). It can be None, '', '\n', '\r', and '\r\n'. It works as
follows:
* On input, if newline is None, universal newlines mode is
enabled. Lines in the input can end in '\n', '\r', or '\r\n', and
these are translated into '\n' before being returned to the
caller. If it is '', universal newline mode is enabled, but line
endings are returned to the caller untranslated. If it has any of
the other legal values, input lines are only terminated by the given
string, and the line ending is returned to the caller untranslated.
* On output, if newline is None, any '\n' characters written are
translated to the system default line separator, os.linesep. If
newline is '' or '\n', no translation takes place. If newline is any
of the other legal values, any '\n' characters written are translated
to the given string.
If closefd is False, the underlying file descriptor will be kept open
when the file is closed. This does not work when a file name is given
and must be True in that case.
A custom opener can be used by passing a callable as *opener*. The
underlying file descriptor for the file object is then obtained by
calling *opener* with (*file*, *flags*). *opener* must return an open
file descriptor (passing os.open as *opener* results in functionality
similar to passing None).
open() returns a file object whose type depends on the mode, and
through which the standard file operations such as reading and writing
are performed. When open() is used to open a file in a text mode ('w',
'r', 'wt', 'rt', etc.), it returns a TextIOWrapper. When used to open
a file in a binary mode, the returned class varies: in read binary
mode, it returns a BufferedReader; in write binary and append binary
modes, it returns a BufferedWriter, and in read/write mode, it returns
a BufferedRandom.
It is also possible to use a string or bytearray as a file for both
reading and writing. For strings StringIO can be used like a file
opened in a text mode, and for bytes a BytesIO can be used like a file
opened in a binary mode.
[clinic start generated code]*/
static PyObject *
_io_open_impl(PyObject *module, PyObject *file, const char *mode,
int buffering, const char *encoding, const char *errors,
const char *newline, int closefd, PyObject *opener)
/*[clinic end generated code: output=aefafc4ce2b46dc0 input=f4e1ca75223987bc]*/
{
unsigned i;
int creating = 0, reading = 0, writing = 0, appending = 0, updating = 0;
int text = 0, binary = 0, universal = 0;
char rawmode[6], *m;
int line_buffering, is_number;
long isatty;
PyObject *raw, *modeobj = NULL, *buffer, *wrapper, *result = NULL, *path_or_fd = NULL;
_Py_IDENTIFIER(_blksize);
_Py_IDENTIFIER(isatty);
_Py_IDENTIFIER(mode);
_Py_IDENTIFIER(close);
is_number = PyNumber_Check(file);
if (is_number) {
path_or_fd = file;
Py_INCREF(path_or_fd);
} else {
path_or_fd = PyOS_FSPath(file);
if (path_or_fd == NULL) {
return NULL;
}
}
if (!is_number &&
!PyUnicode_Check(path_or_fd) &&
!PyBytes_Check(path_or_fd)) {
PyErr_Format(PyExc_TypeError, "invalid file: %R", file);
goto error;
}
/* Decode mode */
for (i = 0; i < strlen(mode); i++) {
char c = mode[i];
switch (c) {
case 'x':
creating = 1;
break;
case 'r':
reading = 1;
break;
case 'w':
writing = 1;
break;
case 'a':
appending = 1;
break;
case '+':
updating = 1;
break;
case 't':
text = 1;
break;
case 'b':
binary = 1;
break;
case 'U':
universal = 1;
reading = 1;
break;
default:
goto invalid_mode;
}
/* c must not be duplicated */
if (strchr(mode+i+1, c)) {
invalid_mode:
PyErr_Format(PyExc_ValueError, "invalid mode: '%s'", mode);
goto error;
}
}
m = rawmode;
if (creating) *(m++) = 'x';
if (reading) *(m++) = 'r';
if (writing) *(m++) = 'w';
if (appending) *(m++) = 'a';
if (updating) *(m++) = '+';
*m = '\0';
/* Parameters validation */
if (universal) {
if (creating || writing || appending || updating) {
PyErr_SetString(PyExc_ValueError,
"mode U cannot be combined with x', 'w', 'a', or '+'");
goto error;
}
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"'U' mode is deprecated", 1) < 0)
goto error;
reading = 1;
}
if (text && binary) {
PyErr_SetString(PyExc_ValueError,
"can't have text and binary mode at once");
goto error;
}
if (creating + reading + writing + appending > 1) {
PyErr_SetString(PyExc_ValueError,
"must have exactly one of create/read/write/append mode");
goto error;
}
if (binary && encoding != NULL) {
PyErr_SetString(PyExc_ValueError,
"binary mode doesn't take an encoding argument");
goto error;
}
if (binary && errors != NULL) {
PyErr_SetString(PyExc_ValueError,
"binary mode doesn't take an errors argument");
goto error;
}
if (binary && newline != NULL) {
PyErr_SetString(PyExc_ValueError,
"binary mode doesn't take a newline argument");
goto error;
}
/* Create the Raw file stream */
{
PyObject *RawIO_class = (PyObject *)&PyFileIO_Type;
#ifdef MS_WINDOWS
if (!Py_LegacyWindowsStdioFlag && _PyIO_get_console_type(path_or_fd) != '\0') {
RawIO_class = (PyObject *)&PyWindowsConsoleIO_Type;
encoding = "utf-8";
}
#endif
raw = PyObject_CallFunction(RawIO_class,
"OsiO", path_or_fd, rawmode, closefd, opener);
}
if (raw == NULL)
goto error;
result = raw;
Py_DECREF(path_or_fd);
path_or_fd = NULL;
modeobj = PyUnicode_FromString(mode);
if (modeobj == NULL)
goto error;
/* buffering */
{
PyObject *res = _PyObject_CallMethodId(raw, &PyId_isatty, NULL);
if (res == NULL)
goto error;
isatty = PyLong_AsLong(res);
Py_DECREF(res);
if (isatty == -1 && PyErr_Occurred())
goto error;
}
if (buffering == 1 || (buffering < 0 && isatty)) {
buffering = -1;
line_buffering = 1;
}
else
line_buffering = 0;
if (buffering < 0) {
PyObject *blksize_obj;
blksize_obj = _PyObject_GetAttrId(raw, &PyId__blksize);
if (blksize_obj == NULL)
goto error;
buffering = PyLong_AsLong(blksize_obj);
Py_DECREF(blksize_obj);
if (buffering == -1 && PyErr_Occurred())
goto error;
}
if (buffering < 0) {
PyErr_SetString(PyExc_ValueError,
"invalid buffering size");
goto error;
}
/* if not buffering, returns the raw file object */
if (buffering == 0) {
if (!binary) {
PyErr_SetString(PyExc_ValueError,
"can't have unbuffered text I/O");
goto error;
}
Py_DECREF(modeobj);
return result;
}
/* wraps into a buffered file */
{
PyObject *Buffered_class;
if (updating)
Buffered_class = (PyObject *)&PyBufferedRandom_Type;
else if (creating || writing || appending)
Buffered_class = (PyObject *)&PyBufferedWriter_Type;
else if (reading)
Buffered_class = (PyObject *)&PyBufferedReader_Type;
else {
PyErr_Format(PyExc_ValueError,
"unknown mode: '%s'", mode);
goto error;
}
buffer = PyObject_CallFunction(Buffered_class, "Oi", raw, buffering);
}
if (buffer == NULL)
goto error;
result = buffer;
Py_DECREF(raw);
/* if binary, returns the buffered file */
if (binary) {
Py_DECREF(modeobj);
return result;
}
/* wraps into a TextIOWrapper */
wrapper = PyObject_CallFunction((PyObject *)&PyTextIOWrapper_Type,
"Osssi",
buffer,
encoding, errors, newline,
line_buffering);
if (wrapper == NULL)
goto error;
result = wrapper;
Py_DECREF(buffer);
if (_PyObject_SetAttrId(wrapper, &PyId_mode, modeobj) < 0)
goto error;
Py_DECREF(modeobj);
return result;
error:
if (result != NULL) {
PyObject *exc, *val, *tb, *close_result;
PyErr_Fetch(&exc, &val, &tb);
close_result = _PyObject_CallMethodId(result, &PyId_close, NULL);
_PyErr_ChainExceptions(exc, val, tb);
Py_XDECREF(close_result);
Py_DECREF(result);
}
Py_XDECREF(path_or_fd);
Py_XDECREF(modeobj);
return NULL;
}
/*
* Private helpers for the io module.
*/
Py_off_t
PyNumber_AsOff_t(PyObject *item, PyObject *err)
{
Py_off_t result;
PyObject *runerr;
PyObject *value = PyNumber_Index(item);
if (value == NULL)
return -1;
/* We're done if PyLong_AsSsize_t() returns without error. */
result = PyLong_AsOff_t(value);
if (result != -1 || !(runerr = PyErr_Occurred()))
goto finish;
/* Error handling code -- only manage OverflowError differently */
if (!PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError))
goto finish;
PyErr_Clear();
/* If no error-handling desired then the default clipping
is sufficient.
*/
if (!err) {
assert(PyLong_Check(value));
/* Whether or not it is less than or equal to
zero is determined by the sign of ob_size
*/
if (_PyLong_Sign(value) < 0)
result = PY_OFF_T_MIN;
else
result = PY_OFF_T_MAX;
}
else {
/* Otherwise replace the error with caller's error object. */
PyErr_Format(err,
"cannot fit '%.200s' into an offset-sized integer",
item->ob_type->tp_name);
}
finish:
Py_DECREF(value);
return result;
}
/* Basically the "n" format code with the ability to turn None into -1. */
int
_PyIO_ConvertSsize_t(PyObject *obj, void *result) {
Py_ssize_t limit;
if (obj == Py_None) {
limit = -1;
}
else if (PyNumber_Check(obj)) {
limit = PyNumber_AsSsize_t(obj, PyExc_OverflowError);
if (limit == -1 && PyErr_Occurred())
return 0;
}
else {
PyErr_Format(PyExc_TypeError,
"integer argument expected, got '%.200s'",
Py_TYPE(obj)->tp_name);
return 0;
}
*((Py_ssize_t *)result) = limit;
return 1;
}
_PyIO_State *
_PyIO_get_module_state(void)
{
PyObject *mod = PyState_FindModule(&_PyIO_Module);
_PyIO_State *state;
if (mod == NULL || (state = IO_MOD_STATE(mod)) == NULL) {
PyErr_SetString(PyExc_RuntimeError,
"could not find io module state "
"(interpreter shutdown?)");
return NULL;
}
return state;
}
PyObject *
_PyIO_get_locale_module(_PyIO_State *state)
{
PyObject *mod;
if (state->locale_module != NULL) {
assert(PyWeakref_CheckRef(state->locale_module));
mod = PyWeakref_GET_OBJECT(state->locale_module);
if (mod != Py_None) {
Py_INCREF(mod);
return mod;
}
Py_CLEAR(state->locale_module);
}
mod = PyImport_ImportModule("_bootlocale");
if (mod == NULL)
return NULL;
state->locale_module = PyWeakref_NewRef(mod, NULL);
if (state->locale_module == NULL) {
Py_DECREF(mod);
return NULL;
}
return mod;
}
static int
iomodule_traverse(PyObject *mod, visitproc visit, void *arg) {
_PyIO_State *state = IO_MOD_STATE(mod);
if (!state->initialized)
return 0;
if (state->locale_module != NULL) {
Py_VISIT(state->locale_module);
}
Py_VISIT(state->unsupported_operation);
return 0;
}
static int
iomodule_clear(PyObject *mod) {
_PyIO_State *state = IO_MOD_STATE(mod);
if (!state->initialized)
return 0;
if (state->locale_module != NULL)
Py_CLEAR(state->locale_module);
Py_CLEAR(state->unsupported_operation);
return 0;
}
static void
iomodule_free(PyObject *mod) {
iomodule_clear(mod);
}
/*
* Module definition
*/
#include "clinic/_iomodule.c.h"
static PyMethodDef module_methods[] = {
_IO_OPEN_METHODDEF
{NULL, NULL}
};
struct PyModuleDef _PyIO_Module = {
PyModuleDef_HEAD_INIT,
"io",
module_doc,
sizeof(_PyIO_State),
module_methods,
NULL,
iomodule_traverse,
iomodule_clear,
(freefunc)iomodule_free,
};
PyMODINIT_FUNC
PyInit__io(void)
{
PyObject *m = PyModule_Create(&_PyIO_Module);
_PyIO_State *state = NULL;
if (m == NULL)
return NULL;
state = IO_MOD_STATE(m);
state->initialized = 0;
#define ADD_TYPE(type, name) \
if (PyType_Ready(type) < 0) \
goto fail; \
Py_INCREF(type); \
if (PyModule_AddObject(m, name, (PyObject *)type) < 0) { \
Py_DECREF(type); \
goto fail; \
}
/* DEFAULT_BUFFER_SIZE */
if (PyModule_AddIntMacro(m, DEFAULT_BUFFER_SIZE) < 0)
goto fail;
/* UnsupportedOperation inherits from ValueError and IOError */
state->unsupported_operation = PyObject_CallFunction(
(PyObject *)&PyType_Type, "s(OO){}",
"UnsupportedOperation", PyExc_OSError, PyExc_ValueError);
if (state->unsupported_operation == NULL)
goto fail;
Py_INCREF(state->unsupported_operation);
if (PyModule_AddObject(m, "UnsupportedOperation",
state->unsupported_operation) < 0)
goto fail;
/* BlockingIOError, for compatibility */
Py_INCREF(PyExc_BlockingIOError);
if (PyModule_AddObject(m, "BlockingIOError",
(PyObject *) PyExc_BlockingIOError) < 0)
goto fail;
/* Concrete base types of the IO ABCs.
(the ABCs themselves are declared through inheritance in io.py)
*/
ADD_TYPE(&PyIOBase_Type, "_IOBase");
ADD_TYPE(&PyRawIOBase_Type, "_RawIOBase");
ADD_TYPE(&PyBufferedIOBase_Type, "_BufferedIOBase");
ADD_TYPE(&PyTextIOBase_Type, "_TextIOBase");
/* Implementation of concrete IO objects. */
/* FileIO */
PyFileIO_Type.tp_base = &PyRawIOBase_Type;
ADD_TYPE(&PyFileIO_Type, "FileIO");
/* BytesIO */
PyBytesIO_Type.tp_base = &PyBufferedIOBase_Type;
ADD_TYPE(&PyBytesIO_Type, "BytesIO");
if (PyType_Ready(&_PyBytesIOBuffer_Type) < 0)
goto fail;
/* StringIO */
PyStringIO_Type.tp_base = &PyTextIOBase_Type;
ADD_TYPE(&PyStringIO_Type, "StringIO");
#ifdef MS_WINDOWS
/* WindowsConsoleIO */
PyWindowsConsoleIO_Type.tp_base = &PyRawIOBase_Type;
ADD_TYPE(&PyWindowsConsoleIO_Type, "_WindowsConsoleIO");
#endif
/* BufferedReader */
PyBufferedReader_Type.tp_base = &PyBufferedIOBase_Type;
ADD_TYPE(&PyBufferedReader_Type, "BufferedReader");
/* BufferedWriter */
PyBufferedWriter_Type.tp_base = &PyBufferedIOBase_Type;
ADD_TYPE(&PyBufferedWriter_Type, "BufferedWriter");
/* BufferedRWPair */
PyBufferedRWPair_Type.tp_base = &PyBufferedIOBase_Type;
ADD_TYPE(&PyBufferedRWPair_Type, "BufferedRWPair");
/* BufferedRandom */
PyBufferedRandom_Type.tp_base = &PyBufferedIOBase_Type;
ADD_TYPE(&PyBufferedRandom_Type, "BufferedRandom");
/* TextIOWrapper */
PyTextIOWrapper_Type.tp_base = &PyTextIOBase_Type;
ADD_TYPE(&PyTextIOWrapper_Type, "TextIOWrapper");
/* IncrementalNewlineDecoder */
ADD_TYPE(&PyIncrementalNewlineDecoder_Type, "IncrementalNewlineDecoder");
/* Interned strings */
#define ADD_INTERNED(name) \
if (!_PyIO_str_ ## name && \
!(_PyIO_str_ ## name = PyUnicode_InternFromString(# name))) \
goto fail;
ADD_INTERNED(close)
ADD_INTERNED(closed)
ADD_INTERNED(decode)
ADD_INTERNED(encode)
ADD_INTERNED(fileno)
ADD_INTERNED(flush)
ADD_INTERNED(getstate)
ADD_INTERNED(isatty)
ADD_INTERNED(newlines)
ADD_INTERNED(read)
ADD_INTERNED(read1)
ADD_INTERNED(readable)
ADD_INTERNED(readall)
ADD_INTERNED(readinto)
ADD_INTERNED(readline)
ADD_INTERNED(reset)
ADD_INTERNED(seek)
ADD_INTERNED(seekable)
ADD_INTERNED(setstate)
ADD_INTERNED(tell)
ADD_INTERNED(truncate)
ADD_INTERNED(write)
ADD_INTERNED(writable)
if (!_PyIO_str_nl &&
!(_PyIO_str_nl = PyUnicode_InternFromString("\n")))
goto fail;
if (!_PyIO_empty_str &&
!(_PyIO_empty_str = PyUnicode_FromStringAndSize(NULL, 0)))
goto fail;
if (!_PyIO_empty_bytes &&
!(_PyIO_empty_bytes = PyBytes_FromStringAndSize(NULL, 0)))
goto fail;
if (!_PyIO_zero &&
!(_PyIO_zero = PyLong_FromLong(0L)))
goto fail;
state->initialized = 1;
return m;
fail:
Py_XDECREF(state->unsupported_operation);
Py_DECREF(m);
return NULL;
}

View file

@ -0,0 +1,188 @@
/*
* Declarations shared between the different parts of the io module
*/
/* ABCs */
extern PyTypeObject PyIOBase_Type;
extern PyTypeObject PyRawIOBase_Type;
extern PyTypeObject PyBufferedIOBase_Type;
extern PyTypeObject PyTextIOBase_Type;
/* Concrete classes */
extern PyTypeObject PyFileIO_Type;
extern PyTypeObject PyBytesIO_Type;
extern PyTypeObject PyStringIO_Type;
extern PyTypeObject PyBufferedReader_Type;
extern PyTypeObject PyBufferedWriter_Type;
extern PyTypeObject PyBufferedRWPair_Type;
extern PyTypeObject PyBufferedRandom_Type;
extern PyTypeObject PyTextIOWrapper_Type;
extern PyTypeObject PyIncrementalNewlineDecoder_Type;
#ifndef Py_LIMITED_API
#ifdef MS_WINDOWS
extern PyTypeObject PyWindowsConsoleIO_Type;
PyAPI_DATA(PyObject *) _PyWindowsConsoleIO_Type;
#define PyWindowsConsoleIO_Check(op) (PyObject_TypeCheck((op), (PyTypeObject*)_PyWindowsConsoleIO_Type))
#endif /* MS_WINDOWS */
#endif /* Py_LIMITED_API */
extern int _PyIO_ConvertSsize_t(PyObject *, void *);
/* These functions are used as METH_NOARGS methods, are normally called
* with args=NULL, and return a new reference.
* BUT when args=Py_True is passed, they return a borrowed reference.
*/
extern PyObject* _PyIOBase_check_readable(PyObject *self, PyObject *args);
extern PyObject* _PyIOBase_check_writable(PyObject *self, PyObject *args);
extern PyObject* _PyIOBase_check_seekable(PyObject *self, PyObject *args);
extern PyObject* _PyIOBase_check_closed(PyObject *self, PyObject *args);
/* Helper for finalization.
This function will revive an object ready to be deallocated and try to
close() it. It returns 0 if the object can be destroyed, or -1 if it
is alive again. */
extern int _PyIOBase_finalize(PyObject *self);
/* Returns true if the given FileIO object is closed.
Doesn't check the argument type, so be careful! */
extern int _PyFileIO_closed(PyObject *self);
/* Shortcut to the core of the IncrementalNewlineDecoder.decode method */
extern PyObject *_PyIncrementalNewlineDecoder_decode(
PyObject *self, PyObject *input, int final);
/* Finds the first line ending between `start` and `end`.
If found, returns the index after the line ending and doesn't touch
`*consumed`.
If not found, returns -1 and sets `*consumed` to the number of characters
which can be safely put aside until another search.
NOTE: for performance reasons, `end` must point to a NUL character ('\0').
Otherwise, the function will scan further and return garbage.
There are three modes, in order of priority:
* translated: Only find \n (assume newlines already translated)
* universal: Use universal newlines algorithm
* Otherwise, the line ending is specified by readnl, a str object */
extern Py_ssize_t _PyIO_find_line_ending(
int translated, int universal, PyObject *readnl,
int kind, const char *start, const char *end, Py_ssize_t *consumed);
/* Return 1 if an EnvironmentError with errno == EINTR is set (and then
clears the error indicator), 0 otherwise.
Should only be called when PyErr_Occurred() is true.
*/
extern int _PyIO_trap_eintr(void);
#define DEFAULT_BUFFER_SIZE (8 * 1024) /* bytes */
/*
* Offset type for positioning.
*/
/* Printing a variable of type off_t (with e.g., PyUnicode_FromFormat)
correctly and without producing compiler warnings is surprisingly painful.
We identify an integer type whose size matches off_t and then: (1) cast the
off_t to that integer type and (2) use the appropriate conversion
specification. The cast is necessary: gcc complains about formatting a
long with "%lld" even when both long and long long have the same
precision. */
#ifdef MS_WINDOWS
/* Windows uses long long for offsets */
typedef long long Py_off_t;
# define PyLong_AsOff_t PyLong_AsLongLong
# define PyLong_FromOff_t PyLong_FromLongLong
# define PY_OFF_T_MAX LLONG_MAX
# define PY_OFF_T_MIN LLONG_MIN
# define PY_OFF_T_COMPAT long long /* type compatible with off_t */
# define PY_PRIdOFF "lld" /* format to use for that type */
#else
/* Other platforms use off_t */
typedef off_t Py_off_t;
#if (SIZEOF_OFF_T == SIZEOF_SIZE_T)
# define PyLong_AsOff_t PyLong_AsSsize_t
# define PyLong_FromOff_t PyLong_FromSsize_t
# define PY_OFF_T_MAX PY_SSIZE_T_MAX
# define PY_OFF_T_MIN PY_SSIZE_T_MIN
# define PY_OFF_T_COMPAT Py_ssize_t
# define PY_PRIdOFF "zd"
#elif (SIZEOF_OFF_T == SIZEOF_LONG_LONG)
# define PyLong_AsOff_t PyLong_AsLongLong
# define PyLong_FromOff_t PyLong_FromLongLong
# define PY_OFF_T_MAX LLONG_MAX
# define PY_OFF_T_MIN LLONG_MIN
# define PY_OFF_T_COMPAT long long
# define PY_PRIdOFF "lld"
#elif (SIZEOF_OFF_T == SIZEOF_LONG)
# define PyLong_AsOff_t PyLong_AsLong
# define PyLong_FromOff_t PyLong_FromLong
# define PY_OFF_T_MAX LONG_MAX
# define PY_OFF_T_MIN LONG_MIN
# define PY_OFF_T_COMPAT long
# define PY_PRIdOFF "ld"
#else
# error off_t does not match either size_t, long, or long long!
#endif
#endif
extern Py_off_t PyNumber_AsOff_t(PyObject *item, PyObject *err);
/* Implementation details */
/* IO module structure */
extern PyModuleDef _PyIO_Module;
typedef struct {
int initialized;
PyObject *locale_module;
PyObject *unsupported_operation;
} _PyIO_State;
#define IO_MOD_STATE(mod) ((_PyIO_State *)PyModule_GetState(mod))
#define IO_STATE() _PyIO_get_module_state()
extern _PyIO_State *_PyIO_get_module_state(void);
extern PyObject *_PyIO_get_locale_module(_PyIO_State *);
#ifdef MS_WINDOWS
extern char _PyIO_get_console_type(PyObject *);
#endif
extern PyObject *_PyIO_str_close;
extern PyObject *_PyIO_str_closed;
extern PyObject *_PyIO_str_decode;
extern PyObject *_PyIO_str_encode;
extern PyObject *_PyIO_str_fileno;
extern PyObject *_PyIO_str_flush;
extern PyObject *_PyIO_str_getstate;
extern PyObject *_PyIO_str_isatty;
extern PyObject *_PyIO_str_newlines;
extern PyObject *_PyIO_str_nl;
extern PyObject *_PyIO_str_read;
extern PyObject *_PyIO_str_read1;
extern PyObject *_PyIO_str_readable;
extern PyObject *_PyIO_str_readall;
extern PyObject *_PyIO_str_readinto;
extern PyObject *_PyIO_str_readline;
extern PyObject *_PyIO_str_reset;
extern PyObject *_PyIO_str_seek;
extern PyObject *_PyIO_str_seekable;
extern PyObject *_PyIO_str_setstate;
extern PyObject *_PyIO_str_tell;
extern PyObject *_PyIO_str_truncate;
extern PyObject *_PyIO_str_writable;
extern PyObject *_PyIO_str_write;
extern PyObject *_PyIO_empty_str;
extern PyObject *_PyIO_empty_bytes;
extern PyObject *_PyIO_zero;
extern PyTypeObject _PyBytesIOBuffer_Type;

File diff suppressed because it is too large Load diff

1184
third_party/python/Modules/_io/bytesio.c vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,161 @@
/*[clinic input]
preserve
[clinic start generated code]*/
PyDoc_STRVAR(_io_open__doc__,
"open($module, /, file, mode=\'r\', buffering=-1, encoding=None,\n"
" errors=None, newline=None, closefd=True, opener=None)\n"
"--\n"
"\n"
"Open file and return a stream. Raise IOError upon failure.\n"
"\n"
"file is either a text or byte string giving the name (and the path\n"
"if the file isn\'t in the current working directory) of the file to\n"
"be opened or an integer file descriptor of the file to be\n"
"wrapped. (If a file descriptor is given, it is closed when the\n"
"returned I/O object is closed, unless closefd is set to False.)\n"
"\n"
"mode is an optional string that specifies the mode in which the file\n"
"is opened. It defaults to \'r\' which means open for reading in text\n"
"mode. Other common values are \'w\' for writing (truncating the file if\n"
"it already exists), \'x\' for creating and writing to a new file, and\n"
"\'a\' for appending (which on some Unix systems, means that all writes\n"
"append to the end of the file regardless of the current seek position).\n"
"In text mode, if encoding is not specified the encoding used is platform\n"
"dependent: locale.getpreferredencoding(False) is called to get the\n"
"current locale encoding. (For reading and writing raw bytes use binary\n"
"mode and leave encoding unspecified.) The available modes are:\n"
"\n"
"========= ===============================================================\n"
"Character Meaning\n"
"--------- ---------------------------------------------------------------\n"
"\'r\' open for reading (default)\n"
"\'w\' open for writing, truncating the file first\n"
"\'x\' create a new file and open it for writing\n"
"\'a\' open for writing, appending to the end of the file if it exists\n"
"\'b\' binary mode\n"
"\'t\' text mode (default)\n"
"\'+\' open a disk file for updating (reading and writing)\n"
"\'U\' universal newline mode (deprecated)\n"
"========= ===============================================================\n"
"\n"
"The default mode is \'rt\' (open for reading text). For binary random\n"
"access, the mode \'w+b\' opens and truncates the file to 0 bytes, while\n"
"\'r+b\' opens the file without truncation. The \'x\' mode implies \'w\' and\n"
"raises an `FileExistsError` if the file already exists.\n"
"\n"
"Python distinguishes between files opened in binary and text modes,\n"
"even when the underlying operating system doesn\'t. Files opened in\n"
"binary mode (appending \'b\' to the mode argument) return contents as\n"
"bytes objects without any decoding. In text mode (the default, or when\n"
"\'t\' is appended to the mode argument), the contents of the file are\n"
"returned as strings, the bytes having been first decoded using a\n"
"platform-dependent encoding or using the specified encoding if given.\n"
"\n"
"\'U\' mode is deprecated and will raise an exception in future versions\n"
"of Python. It has no effect in Python 3. Use newline to control\n"
"universal newlines mode.\n"
"\n"
"buffering is an optional integer used to set the buffering policy.\n"
"Pass 0 to switch buffering off (only allowed in binary mode), 1 to select\n"
"line buffering (only usable in text mode), and an integer > 1 to indicate\n"
"the size of a fixed-size chunk buffer. When no buffering argument is\n"
"given, the default buffering policy works as follows:\n"
"\n"
"* Binary files are buffered in fixed-size chunks; the size of the buffer\n"
" is chosen using a heuristic trying to determine the underlying device\'s\n"
" \"block size\" and falling back on `io.DEFAULT_BUFFER_SIZE`.\n"
" On many systems, the buffer will typically be 4096 or 8192 bytes long.\n"
"\n"
"* \"Interactive\" text files (files for which isatty() returns True)\n"
" use line buffering. Other text files use the policy described above\n"
" for binary files.\n"
"\n"
"encoding is the name of the encoding used to decode or encode the\n"
"file. This should only be used in text mode. The default encoding is\n"
"platform dependent, but any encoding supported by Python can be\n"
"passed. See the codecs module for the list of supported encodings.\n"
"\n"
"errors is an optional string that specifies how encoding errors are to\n"
"be handled---this argument should not be used in binary mode. Pass\n"
"\'strict\' to raise a ValueError exception if there is an encoding error\n"
"(the default of None has the same effect), or pass \'ignore\' to ignore\n"
"errors. (Note that ignoring encoding errors can lead to data loss.)\n"
"See the documentation for codecs.register or run \'help(codecs.Codec)\'\n"
"for a list of the permitted encoding error strings.\n"
"\n"
"newline controls how universal newlines works (it only applies to text\n"
"mode). It can be None, \'\', \'\\n\', \'\\r\', and \'\\r\\n\'. It works as\n"
"follows:\n"
"\n"
"* On input, if newline is None, universal newlines mode is\n"
" enabled. Lines in the input can end in \'\\n\', \'\\r\', or \'\\r\\n\', and\n"
" these are translated into \'\\n\' before being returned to the\n"
" caller. If it is \'\', universal newline mode is enabled, but line\n"
" endings are returned to the caller untranslated. If it has any of\n"
" the other legal values, input lines are only terminated by the given\n"
" string, and the line ending is returned to the caller untranslated.\n"
"\n"
"* On output, if newline is None, any \'\\n\' characters written are\n"
" translated to the system default line separator, os.linesep. If\n"
" newline is \'\' or \'\\n\', no translation takes place. If newline is any\n"
" of the other legal values, any \'\\n\' characters written are translated\n"
" to the given string.\n"
"\n"
"If closefd is False, the underlying file descriptor will be kept open\n"
"when the file is closed. This does not work when a file name is given\n"
"and must be True in that case.\n"
"\n"
"A custom opener can be used by passing a callable as *opener*. The\n"
"underlying file descriptor for the file object is then obtained by\n"
"calling *opener* with (*file*, *flags*). *opener* must return an open\n"
"file descriptor (passing os.open as *opener* results in functionality\n"
"similar to passing None).\n"
"\n"
"open() returns a file object whose type depends on the mode, and\n"
"through which the standard file operations such as reading and writing\n"
"are performed. When open() is used to open a file in a text mode (\'w\',\n"
"\'r\', \'wt\', \'rt\', etc.), it returns a TextIOWrapper. When used to open\n"
"a file in a binary mode, the returned class varies: in read binary\n"
"mode, it returns a BufferedReader; in write binary and append binary\n"
"modes, it returns a BufferedWriter, and in read/write mode, it returns\n"
"a BufferedRandom.\n"
"\n"
"It is also possible to use a string or bytearray as a file for both\n"
"reading and writing. For strings StringIO can be used like a file\n"
"opened in a text mode, and for bytes a BytesIO can be used like a file\n"
"opened in a binary mode.");
#define _IO_OPEN_METHODDEF \
{"open", (PyCFunction)_io_open, METH_FASTCALL, _io_open__doc__},
static PyObject *
_io_open_impl(PyObject *module, PyObject *file, const char *mode,
int buffering, const char *encoding, const char *errors,
const char *newline, int closefd, PyObject *opener);
static PyObject *
_io_open(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"file", "mode", "buffering", "encoding", "errors", "newline", "closefd", "opener", NULL};
static _PyArg_Parser _parser = {"O|sizzziO:open", _keywords, 0};
PyObject *file;
const char *mode = "r";
int buffering = -1;
const char *encoding = NULL;
const char *errors = NULL;
const char *newline = NULL;
int closefd = 1;
PyObject *opener = Py_None;
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
&file, &mode, &buffering, &encoding, &errors, &newline, &closefd, &opener)) {
goto exit;
}
return_value = _io_open_impl(module, file, mode, buffering, encoding, errors, newline, closefd, opener);
exit:
return return_value;
}
/*[clinic end generated code: output=c5b8fc8b83102bbf input=a9049054013a1b77]*/

View file

@ -0,0 +1,478 @@
/*[clinic input]
preserve
[clinic start generated code]*/
PyDoc_STRVAR(_io__BufferedIOBase_readinto__doc__,
"readinto($self, buffer, /)\n"
"--\n"
"\n");
#define _IO__BUFFEREDIOBASE_READINTO_METHODDEF \
{"readinto", (PyCFunction)_io__BufferedIOBase_readinto, METH_O, _io__BufferedIOBase_readinto__doc__},
static PyObject *
_io__BufferedIOBase_readinto_impl(PyObject *self, Py_buffer *buffer);
static PyObject *
_io__BufferedIOBase_readinto(PyObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
}
return_value = _io__BufferedIOBase_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
if (buffer.obj) {
PyBuffer_Release(&buffer);
}
return return_value;
}
PyDoc_STRVAR(_io__BufferedIOBase_readinto1__doc__,
"readinto1($self, buffer, /)\n"
"--\n"
"\n");
#define _IO__BUFFEREDIOBASE_READINTO1_METHODDEF \
{"readinto1", (PyCFunction)_io__BufferedIOBase_readinto1, METH_O, _io__BufferedIOBase_readinto1__doc__},
static PyObject *
_io__BufferedIOBase_readinto1_impl(PyObject *self, Py_buffer *buffer);
static PyObject *
_io__BufferedIOBase_readinto1(PyObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {
goto exit;
}
return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer);
exit:
/* Cleanup for buffer */
if (buffer.obj) {
PyBuffer_Release(&buffer);
}
return return_value;
}
PyDoc_STRVAR(_io__BufferedIOBase_detach__doc__,
"detach($self, /)\n"
"--\n"
"\n"
"Disconnect this buffer from its underlying raw stream and return it.\n"
"\n"
"After the raw stream has been detached, the buffer is in an unusable\n"
"state.");
#define _IO__BUFFEREDIOBASE_DETACH_METHODDEF \
{"detach", (PyCFunction)_io__BufferedIOBase_detach, METH_NOARGS, _io__BufferedIOBase_detach__doc__},
static PyObject *
_io__BufferedIOBase_detach_impl(PyObject *self);
static PyObject *
_io__BufferedIOBase_detach(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__BufferedIOBase_detach_impl(self);
}
PyDoc_STRVAR(_io__Buffered_peek__doc__,
"peek($self, size=0, /)\n"
"--\n"
"\n");
#define _IO__BUFFERED_PEEK_METHODDEF \
{"peek", (PyCFunction)_io__Buffered_peek, METH_VARARGS, _io__Buffered_peek__doc__},
static PyObject *
_io__Buffered_peek_impl(buffered *self, Py_ssize_t size);
static PyObject *
_io__Buffered_peek(buffered *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_ssize_t size = 0;
if (!PyArg_ParseTuple(args, "|n:peek",
&size)) {
goto exit;
}
return_value = _io__Buffered_peek_impl(self, size);
exit:
return return_value;
}
PyDoc_STRVAR(_io__Buffered_read__doc__,
"read($self, size=-1, /)\n"
"--\n"
"\n");
#define _IO__BUFFERED_READ_METHODDEF \
{"read", (PyCFunction)_io__Buffered_read, METH_VARARGS, _io__Buffered_read__doc__},
static PyObject *
_io__Buffered_read_impl(buffered *self, Py_ssize_t n);
static PyObject *
_io__Buffered_read(buffered *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_ssize_t n = -1;
if (!PyArg_ParseTuple(args, "|O&:read",
_PyIO_ConvertSsize_t, &n)) {
goto exit;
}
return_value = _io__Buffered_read_impl(self, n);
exit:
return return_value;
}
PyDoc_STRVAR(_io__Buffered_read1__doc__,
"read1($self, size, /)\n"
"--\n"
"\n");
#define _IO__BUFFERED_READ1_METHODDEF \
{"read1", (PyCFunction)_io__Buffered_read1, METH_O, _io__Buffered_read1__doc__},
static PyObject *
_io__Buffered_read1_impl(buffered *self, Py_ssize_t n);
static PyObject *
_io__Buffered_read1(buffered *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_ssize_t n;
if (!PyArg_Parse(arg, "n:read1", &n)) {
goto exit;
}
return_value = _io__Buffered_read1_impl(self, n);
exit:
return return_value;
}
PyDoc_STRVAR(_io__Buffered_readinto__doc__,
"readinto($self, buffer, /)\n"
"--\n"
"\n");
#define _IO__BUFFERED_READINTO_METHODDEF \
{"readinto", (PyCFunction)_io__Buffered_readinto, METH_O, _io__Buffered_readinto__doc__},
static PyObject *
_io__Buffered_readinto_impl(buffered *self, Py_buffer *buffer);
static PyObject *
_io__Buffered_readinto(buffered *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
}
return_value = _io__Buffered_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
if (buffer.obj) {
PyBuffer_Release(&buffer);
}
return return_value;
}
PyDoc_STRVAR(_io__Buffered_readinto1__doc__,
"readinto1($self, buffer, /)\n"
"--\n"
"\n");
#define _IO__BUFFERED_READINTO1_METHODDEF \
{"readinto1", (PyCFunction)_io__Buffered_readinto1, METH_O, _io__Buffered_readinto1__doc__},
static PyObject *
_io__Buffered_readinto1_impl(buffered *self, Py_buffer *buffer);
static PyObject *
_io__Buffered_readinto1(buffered *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {
goto exit;
}
return_value = _io__Buffered_readinto1_impl(self, &buffer);
exit:
/* Cleanup for buffer */
if (buffer.obj) {
PyBuffer_Release(&buffer);
}
return return_value;
}
PyDoc_STRVAR(_io__Buffered_readline__doc__,
"readline($self, size=-1, /)\n"
"--\n"
"\n");
#define _IO__BUFFERED_READLINE_METHODDEF \
{"readline", (PyCFunction)_io__Buffered_readline, METH_VARARGS, _io__Buffered_readline__doc__},
static PyObject *
_io__Buffered_readline_impl(buffered *self, Py_ssize_t size);
static PyObject *
_io__Buffered_readline(buffered *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_ssize_t size = -1;
if (!PyArg_ParseTuple(args, "|O&:readline",
_PyIO_ConvertSsize_t, &size)) {
goto exit;
}
return_value = _io__Buffered_readline_impl(self, size);
exit:
return return_value;
}
PyDoc_STRVAR(_io__Buffered_seek__doc__,
"seek($self, target, whence=0, /)\n"
"--\n"
"\n");
#define _IO__BUFFERED_SEEK_METHODDEF \
{"seek", (PyCFunction)_io__Buffered_seek, METH_VARARGS, _io__Buffered_seek__doc__},
static PyObject *
_io__Buffered_seek_impl(buffered *self, PyObject *targetobj, int whence);
static PyObject *
_io__Buffered_seek(buffered *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *targetobj;
int whence = 0;
if (!PyArg_ParseTuple(args, "O|i:seek",
&targetobj, &whence)) {
goto exit;
}
return_value = _io__Buffered_seek_impl(self, targetobj, whence);
exit:
return return_value;
}
PyDoc_STRVAR(_io__Buffered_truncate__doc__,
"truncate($self, pos=None, /)\n"
"--\n"
"\n");
#define _IO__BUFFERED_TRUNCATE_METHODDEF \
{"truncate", (PyCFunction)_io__Buffered_truncate, METH_VARARGS, _io__Buffered_truncate__doc__},
static PyObject *
_io__Buffered_truncate_impl(buffered *self, PyObject *pos);
static PyObject *
_io__Buffered_truncate(buffered *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *pos = Py_None;
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
&pos)) {
goto exit;
}
return_value = _io__Buffered_truncate_impl(self, pos);
exit:
return return_value;
}
PyDoc_STRVAR(_io_BufferedReader___init____doc__,
"BufferedReader(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n"
"--\n"
"\n"
"Create a new buffered reader using the given readable raw IO object.");
static int
_io_BufferedReader___init___impl(buffered *self, PyObject *raw,
Py_ssize_t buffer_size);
static int
_io_BufferedReader___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
static const char * const _keywords[] = {"raw", "buffer_size", NULL};
static _PyArg_Parser _parser = {"O|n:BufferedReader", _keywords, 0};
PyObject *raw;
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&raw, &buffer_size)) {
goto exit;
}
return_value = _io_BufferedReader___init___impl((buffered *)self, raw, buffer_size);
exit:
return return_value;
}
PyDoc_STRVAR(_io_BufferedWriter___init____doc__,
"BufferedWriter(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n"
"--\n"
"\n"
"A buffer for a writeable sequential RawIO object.\n"
"\n"
"The constructor creates a BufferedWriter for the given writeable raw\n"
"stream. If the buffer_size is not given, it defaults to\n"
"DEFAULT_BUFFER_SIZE.");
static int
_io_BufferedWriter___init___impl(buffered *self, PyObject *raw,
Py_ssize_t buffer_size);
static int
_io_BufferedWriter___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
static const char * const _keywords[] = {"raw", "buffer_size", NULL};
static _PyArg_Parser _parser = {"O|n:BufferedWriter", _keywords, 0};
PyObject *raw;
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&raw, &buffer_size)) {
goto exit;
}
return_value = _io_BufferedWriter___init___impl((buffered *)self, raw, buffer_size);
exit:
return return_value;
}
PyDoc_STRVAR(_io_BufferedWriter_write__doc__,
"write($self, buffer, /)\n"
"--\n"
"\n");
#define _IO_BUFFEREDWRITER_WRITE_METHODDEF \
{"write", (PyCFunction)_io_BufferedWriter_write, METH_O, _io_BufferedWriter_write__doc__},
static PyObject *
_io_BufferedWriter_write_impl(buffered *self, Py_buffer *buffer);
static PyObject *
_io_BufferedWriter_write(buffered *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:write", &buffer)) {
goto exit;
}
return_value = _io_BufferedWriter_write_impl(self, &buffer);
exit:
/* Cleanup for buffer */
if (buffer.obj) {
PyBuffer_Release(&buffer);
}
return return_value;
}
PyDoc_STRVAR(_io_BufferedRWPair___init____doc__,
"BufferedRWPair(reader, writer, buffer_size=DEFAULT_BUFFER_SIZE, /)\n"
"--\n"
"\n"
"A buffered reader and writer object together.\n"
"\n"
"A buffered reader object and buffered writer object put together to\n"
"form a sequential IO object that can read and write. This is typically\n"
"used with a socket or two-way pipe.\n"
"\n"
"reader and writer are RawIOBase objects that are readable and\n"
"writeable respectively. If the buffer_size is omitted it defaults to\n"
"DEFAULT_BUFFER_SIZE.");
static int
_io_BufferedRWPair___init___impl(rwpair *self, PyObject *reader,
PyObject *writer, Py_ssize_t buffer_size);
static int
_io_BufferedRWPair___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
PyObject *reader;
PyObject *writer;
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
if ((Py_TYPE(self) == &PyBufferedRWPair_Type) &&
!_PyArg_NoKeywords("BufferedRWPair", kwargs)) {
goto exit;
}
if (!PyArg_ParseTuple(args, "OO|n:BufferedRWPair",
&reader, &writer, &buffer_size)) {
goto exit;
}
return_value = _io_BufferedRWPair___init___impl((rwpair *)self, reader, writer, buffer_size);
exit:
return return_value;
}
PyDoc_STRVAR(_io_BufferedRandom___init____doc__,
"BufferedRandom(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n"
"--\n"
"\n"
"A buffered interface to random access streams.\n"
"\n"
"The constructor creates a reader and writer for a seekable stream,\n"
"raw, given in the first argument. If the buffer_size is omitted it\n"
"defaults to DEFAULT_BUFFER_SIZE.");
static int
_io_BufferedRandom___init___impl(buffered *self, PyObject *raw,
Py_ssize_t buffer_size);
static int
_io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
static const char * const _keywords[] = {"raw", "buffer_size", NULL};
static _PyArg_Parser _parser = {"O|n:BufferedRandom", _keywords, 0};
PyObject *raw;
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&raw, &buffer_size)) {
goto exit;
}
return_value = _io_BufferedRandom___init___impl((buffered *)self, raw, buffer_size);
exit:
return return_value;
}
/*[clinic end generated code: output=a956f394ecde4cf9 input=a9049054013a1b77]*/

View file

@ -0,0 +1,431 @@
/*[clinic input]
preserve
[clinic start generated code]*/
PyDoc_STRVAR(_io_BytesIO_readable__doc__,
"readable($self, /)\n"
"--\n"
"\n"
"Returns True if the IO object can be read.");
#define _IO_BYTESIO_READABLE_METHODDEF \
{"readable", (PyCFunction)_io_BytesIO_readable, METH_NOARGS, _io_BytesIO_readable__doc__},
static PyObject *
_io_BytesIO_readable_impl(bytesio *self);
static PyObject *
_io_BytesIO_readable(bytesio *self, PyObject *Py_UNUSED(ignored))
{
return _io_BytesIO_readable_impl(self);
}
PyDoc_STRVAR(_io_BytesIO_writable__doc__,
"writable($self, /)\n"
"--\n"
"\n"
"Returns True if the IO object can be written.");
#define _IO_BYTESIO_WRITABLE_METHODDEF \
{"writable", (PyCFunction)_io_BytesIO_writable, METH_NOARGS, _io_BytesIO_writable__doc__},
static PyObject *
_io_BytesIO_writable_impl(bytesio *self);
static PyObject *
_io_BytesIO_writable(bytesio *self, PyObject *Py_UNUSED(ignored))
{
return _io_BytesIO_writable_impl(self);
}
PyDoc_STRVAR(_io_BytesIO_seekable__doc__,
"seekable($self, /)\n"
"--\n"
"\n"
"Returns True if the IO object can be seeked.");
#define _IO_BYTESIO_SEEKABLE_METHODDEF \
{"seekable", (PyCFunction)_io_BytesIO_seekable, METH_NOARGS, _io_BytesIO_seekable__doc__},
static PyObject *
_io_BytesIO_seekable_impl(bytesio *self);
static PyObject *
_io_BytesIO_seekable(bytesio *self, PyObject *Py_UNUSED(ignored))
{
return _io_BytesIO_seekable_impl(self);
}
PyDoc_STRVAR(_io_BytesIO_flush__doc__,
"flush($self, /)\n"
"--\n"
"\n"
"Does nothing.");
#define _IO_BYTESIO_FLUSH_METHODDEF \
{"flush", (PyCFunction)_io_BytesIO_flush, METH_NOARGS, _io_BytesIO_flush__doc__},
static PyObject *
_io_BytesIO_flush_impl(bytesio *self);
static PyObject *
_io_BytesIO_flush(bytesio *self, PyObject *Py_UNUSED(ignored))
{
return _io_BytesIO_flush_impl(self);
}
PyDoc_STRVAR(_io_BytesIO_getbuffer__doc__,
"getbuffer($self, /)\n"
"--\n"
"\n"
"Get a read-write view over the contents of the BytesIO object.");
#define _IO_BYTESIO_GETBUFFER_METHODDEF \
{"getbuffer", (PyCFunction)_io_BytesIO_getbuffer, METH_NOARGS, _io_BytesIO_getbuffer__doc__},
static PyObject *
_io_BytesIO_getbuffer_impl(bytesio *self);
static PyObject *
_io_BytesIO_getbuffer(bytesio *self, PyObject *Py_UNUSED(ignored))
{
return _io_BytesIO_getbuffer_impl(self);
}
PyDoc_STRVAR(_io_BytesIO_getvalue__doc__,
"getvalue($self, /)\n"
"--\n"
"\n"
"Retrieve the entire contents of the BytesIO object.");
#define _IO_BYTESIO_GETVALUE_METHODDEF \
{"getvalue", (PyCFunction)_io_BytesIO_getvalue, METH_NOARGS, _io_BytesIO_getvalue__doc__},
static PyObject *
_io_BytesIO_getvalue_impl(bytesio *self);
static PyObject *
_io_BytesIO_getvalue(bytesio *self, PyObject *Py_UNUSED(ignored))
{
return _io_BytesIO_getvalue_impl(self);
}
PyDoc_STRVAR(_io_BytesIO_isatty__doc__,
"isatty($self, /)\n"
"--\n"
"\n"
"Always returns False.\n"
"\n"
"BytesIO objects are not connected to a TTY-like device.");
#define _IO_BYTESIO_ISATTY_METHODDEF \
{"isatty", (PyCFunction)_io_BytesIO_isatty, METH_NOARGS, _io_BytesIO_isatty__doc__},
static PyObject *
_io_BytesIO_isatty_impl(bytesio *self);
static PyObject *
_io_BytesIO_isatty(bytesio *self, PyObject *Py_UNUSED(ignored))
{
return _io_BytesIO_isatty_impl(self);
}
PyDoc_STRVAR(_io_BytesIO_tell__doc__,
"tell($self, /)\n"
"--\n"
"\n"
"Current file position, an integer.");
#define _IO_BYTESIO_TELL_METHODDEF \
{"tell", (PyCFunction)_io_BytesIO_tell, METH_NOARGS, _io_BytesIO_tell__doc__},
static PyObject *
_io_BytesIO_tell_impl(bytesio *self);
static PyObject *
_io_BytesIO_tell(bytesio *self, PyObject *Py_UNUSED(ignored))
{
return _io_BytesIO_tell_impl(self);
}
PyDoc_STRVAR(_io_BytesIO_read__doc__,
"read($self, size=None, /)\n"
"--\n"
"\n"
"Read at most size bytes, returned as a bytes object.\n"
"\n"
"If the size argument is negative, read until EOF is reached.\n"
"Return an empty bytes object at EOF.");
#define _IO_BYTESIO_READ_METHODDEF \
{"read", (PyCFunction)_io_BytesIO_read, METH_VARARGS, _io_BytesIO_read__doc__},
static PyObject *
_io_BytesIO_read_impl(bytesio *self, PyObject *arg);
static PyObject *
_io_BytesIO_read(bytesio *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *arg = Py_None;
if (!PyArg_UnpackTuple(args, "read",
0, 1,
&arg)) {
goto exit;
}
return_value = _io_BytesIO_read_impl(self, arg);
exit:
return return_value;
}
PyDoc_STRVAR(_io_BytesIO_read1__doc__,
"read1($self, size, /)\n"
"--\n"
"\n"
"Read at most size bytes, returned as a bytes object.\n"
"\n"
"If the size argument is negative or omitted, read until EOF is reached.\n"
"Return an empty bytes object at EOF.");
#define _IO_BYTESIO_READ1_METHODDEF \
{"read1", (PyCFunction)_io_BytesIO_read1, METH_O, _io_BytesIO_read1__doc__},
PyDoc_STRVAR(_io_BytesIO_readline__doc__,
"readline($self, size=None, /)\n"
"--\n"
"\n"
"Next line from the file, as a bytes object.\n"
"\n"
"Retain newline. A non-negative size argument limits the maximum\n"
"number of bytes to return (an incomplete line may be returned then).\n"
"Return an empty bytes object at EOF.");
#define _IO_BYTESIO_READLINE_METHODDEF \
{"readline", (PyCFunction)_io_BytesIO_readline, METH_VARARGS, _io_BytesIO_readline__doc__},
static PyObject *
_io_BytesIO_readline_impl(bytesio *self, PyObject *arg);
static PyObject *
_io_BytesIO_readline(bytesio *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *arg = Py_None;
if (!PyArg_UnpackTuple(args, "readline",
0, 1,
&arg)) {
goto exit;
}
return_value = _io_BytesIO_readline_impl(self, arg);
exit:
return return_value;
}
PyDoc_STRVAR(_io_BytesIO_readlines__doc__,
"readlines($self, size=None, /)\n"
"--\n"
"\n"
"List of bytes objects, each a line from the file.\n"
"\n"
"Call readline() repeatedly and return a list of the lines so read.\n"
"The optional size argument, if given, is an approximate bound on the\n"
"total number of bytes in the lines returned.");
#define _IO_BYTESIO_READLINES_METHODDEF \
{"readlines", (PyCFunction)_io_BytesIO_readlines, METH_VARARGS, _io_BytesIO_readlines__doc__},
static PyObject *
_io_BytesIO_readlines_impl(bytesio *self, PyObject *arg);
static PyObject *
_io_BytesIO_readlines(bytesio *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *arg = Py_None;
if (!PyArg_UnpackTuple(args, "readlines",
0, 1,
&arg)) {
goto exit;
}
return_value = _io_BytesIO_readlines_impl(self, arg);
exit:
return return_value;
}
PyDoc_STRVAR(_io_BytesIO_readinto__doc__,
"readinto($self, buffer, /)\n"
"--\n"
"\n"
"Read bytes into buffer.\n"
"\n"
"Returns number of bytes read (0 for EOF), or None if the object\n"
"is set not to block and has no data to read.");
#define _IO_BYTESIO_READINTO_METHODDEF \
{"readinto", (PyCFunction)_io_BytesIO_readinto, METH_O, _io_BytesIO_readinto__doc__},
static PyObject *
_io_BytesIO_readinto_impl(bytesio *self, Py_buffer *buffer);
static PyObject *
_io_BytesIO_readinto(bytesio *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
}
return_value = _io_BytesIO_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
if (buffer.obj) {
PyBuffer_Release(&buffer);
}
return return_value;
}
PyDoc_STRVAR(_io_BytesIO_truncate__doc__,
"truncate($self, size=None, /)\n"
"--\n"
"\n"
"Truncate the file to at most size bytes.\n"
"\n"
"Size defaults to the current file position, as returned by tell().\n"
"The current file position is unchanged. Returns the new size.");
#define _IO_BYTESIO_TRUNCATE_METHODDEF \
{"truncate", (PyCFunction)_io_BytesIO_truncate, METH_VARARGS, _io_BytesIO_truncate__doc__},
static PyObject *
_io_BytesIO_truncate_impl(bytesio *self, PyObject *arg);
static PyObject *
_io_BytesIO_truncate(bytesio *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *arg = Py_None;
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
&arg)) {
goto exit;
}
return_value = _io_BytesIO_truncate_impl(self, arg);
exit:
return return_value;
}
PyDoc_STRVAR(_io_BytesIO_seek__doc__,
"seek($self, pos, whence=0, /)\n"
"--\n"
"\n"
"Change stream position.\n"
"\n"
"Seek to byte offset pos relative to position indicated by whence:\n"
" 0 Start of stream (the default). pos should be >= 0;\n"
" 1 Current position - pos may be negative;\n"
" 2 End of stream - pos usually negative.\n"
"Returns the new absolute position.");
#define _IO_BYTESIO_SEEK_METHODDEF \
{"seek", (PyCFunction)_io_BytesIO_seek, METH_VARARGS, _io_BytesIO_seek__doc__},
static PyObject *
_io_BytesIO_seek_impl(bytesio *self, Py_ssize_t pos, int whence);
static PyObject *
_io_BytesIO_seek(bytesio *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_ssize_t pos;
int whence = 0;
if (!PyArg_ParseTuple(args, "n|i:seek",
&pos, &whence)) {
goto exit;
}
return_value = _io_BytesIO_seek_impl(self, pos, whence);
exit:
return return_value;
}
PyDoc_STRVAR(_io_BytesIO_write__doc__,
"write($self, b, /)\n"
"--\n"
"\n"
"Write bytes to file.\n"
"\n"
"Return the number of bytes written.");
#define _IO_BYTESIO_WRITE_METHODDEF \
{"write", (PyCFunction)_io_BytesIO_write, METH_O, _io_BytesIO_write__doc__},
PyDoc_STRVAR(_io_BytesIO_writelines__doc__,
"writelines($self, lines, /)\n"
"--\n"
"\n"
"Write lines to the file.\n"
"\n"
"Note that newlines are not added. lines can be any iterable object\n"
"producing bytes-like objects. This is equivalent to calling write() for\n"
"each element.");
#define _IO_BYTESIO_WRITELINES_METHODDEF \
{"writelines", (PyCFunction)_io_BytesIO_writelines, METH_O, _io_BytesIO_writelines__doc__},
PyDoc_STRVAR(_io_BytesIO_close__doc__,
"close($self, /)\n"
"--\n"
"\n"
"Disable all I/O operations.");
#define _IO_BYTESIO_CLOSE_METHODDEF \
{"close", (PyCFunction)_io_BytesIO_close, METH_NOARGS, _io_BytesIO_close__doc__},
static PyObject *
_io_BytesIO_close_impl(bytesio *self);
static PyObject *
_io_BytesIO_close(bytesio *self, PyObject *Py_UNUSED(ignored))
{
return _io_BytesIO_close_impl(self);
}
PyDoc_STRVAR(_io_BytesIO___init____doc__,
"BytesIO(initial_bytes=b\'\')\n"
"--\n"
"\n"
"Buffered I/O implementation using an in-memory bytes buffer.");
static int
_io_BytesIO___init___impl(bytesio *self, PyObject *initvalue);
static int
_io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
static const char * const _keywords[] = {"initial_bytes", NULL};
static _PyArg_Parser _parser = {"|O:BytesIO", _keywords, 0};
PyObject *initvalue = NULL;
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&initvalue)) {
goto exit;
}
return_value = _io_BytesIO___init___impl((bytesio *)self, initvalue);
exit:
return return_value;
}
/*[clinic end generated code: output=6382e8eb578eea64 input=a9049054013a1b77]*/

View file

@ -0,0 +1,376 @@
/*[clinic input]
preserve
[clinic start generated code]*/
PyDoc_STRVAR(_io_FileIO_close__doc__,
"close($self, /)\n"
"--\n"
"\n"
"Close the file.\n"
"\n"
"A closed file cannot be used for further I/O operations. close() may be\n"
"called more than once without error.");
#define _IO_FILEIO_CLOSE_METHODDEF \
{"close", (PyCFunction)_io_FileIO_close, METH_NOARGS, _io_FileIO_close__doc__},
static PyObject *
_io_FileIO_close_impl(fileio *self);
static PyObject *
_io_FileIO_close(fileio *self, PyObject *Py_UNUSED(ignored))
{
return _io_FileIO_close_impl(self);
}
PyDoc_STRVAR(_io_FileIO___init____doc__,
"FileIO(file, mode=\'r\', closefd=True, opener=None)\n"
"--\n"
"\n"
"Open a file.\n"
"\n"
"The mode can be \'r\' (default), \'w\', \'x\' or \'a\' for reading,\n"
"writing, exclusive creation or appending. The file will be created if it\n"
"doesn\'t exist when opened for writing or appending; it will be truncated\n"
"when opened for writing. A FileExistsError will be raised if it already\n"
"exists when opened for creating. Opening a file for creating implies\n"
"writing so this mode behaves in a similar way to \'w\'.Add a \'+\' to the mode\n"
"to allow simultaneous reading and writing. A custom opener can be used by\n"
"passing a callable as *opener*. The underlying file descriptor for the file\n"
"object is then obtained by calling opener with (*name*, *flags*).\n"
"*opener* must return an open file descriptor (passing os.open as *opener*\n"
"results in functionality similar to passing None).");
static int
_io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
int closefd, PyObject *opener);
static int
_io_FileIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
static const char * const _keywords[] = {"file", "mode", "closefd", "opener", NULL};
static _PyArg_Parser _parser = {"O|siO:FileIO", _keywords, 0};
PyObject *nameobj;
const char *mode = "r";
int closefd = 1;
PyObject *opener = Py_None;
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&nameobj, &mode, &closefd, &opener)) {
goto exit;
}
return_value = _io_FileIO___init___impl((fileio *)self, nameobj, mode, closefd, opener);
exit:
return return_value;
}
PyDoc_STRVAR(_io_FileIO_fileno__doc__,
"fileno($self, /)\n"
"--\n"
"\n"
"Return the underlying file descriptor (an integer).");
#define _IO_FILEIO_FILENO_METHODDEF \
{"fileno", (PyCFunction)_io_FileIO_fileno, METH_NOARGS, _io_FileIO_fileno__doc__},
static PyObject *
_io_FileIO_fileno_impl(fileio *self);
static PyObject *
_io_FileIO_fileno(fileio *self, PyObject *Py_UNUSED(ignored))
{
return _io_FileIO_fileno_impl(self);
}
PyDoc_STRVAR(_io_FileIO_readable__doc__,
"readable($self, /)\n"
"--\n"
"\n"
"True if file was opened in a read mode.");
#define _IO_FILEIO_READABLE_METHODDEF \
{"readable", (PyCFunction)_io_FileIO_readable, METH_NOARGS, _io_FileIO_readable__doc__},
static PyObject *
_io_FileIO_readable_impl(fileio *self);
static PyObject *
_io_FileIO_readable(fileio *self, PyObject *Py_UNUSED(ignored))
{
return _io_FileIO_readable_impl(self);
}
PyDoc_STRVAR(_io_FileIO_writable__doc__,
"writable($self, /)\n"
"--\n"
"\n"
"True if file was opened in a write mode.");
#define _IO_FILEIO_WRITABLE_METHODDEF \
{"writable", (PyCFunction)_io_FileIO_writable, METH_NOARGS, _io_FileIO_writable__doc__},
static PyObject *
_io_FileIO_writable_impl(fileio *self);
static PyObject *
_io_FileIO_writable(fileio *self, PyObject *Py_UNUSED(ignored))
{
return _io_FileIO_writable_impl(self);
}
PyDoc_STRVAR(_io_FileIO_seekable__doc__,
"seekable($self, /)\n"
"--\n"
"\n"
"True if file supports random-access.");
#define _IO_FILEIO_SEEKABLE_METHODDEF \
{"seekable", (PyCFunction)_io_FileIO_seekable, METH_NOARGS, _io_FileIO_seekable__doc__},
static PyObject *
_io_FileIO_seekable_impl(fileio *self);
static PyObject *
_io_FileIO_seekable(fileio *self, PyObject *Py_UNUSED(ignored))
{
return _io_FileIO_seekable_impl(self);
}
PyDoc_STRVAR(_io_FileIO_readinto__doc__,
"readinto($self, buffer, /)\n"
"--\n"
"\n"
"Same as RawIOBase.readinto().");
#define _IO_FILEIO_READINTO_METHODDEF \
{"readinto", (PyCFunction)_io_FileIO_readinto, METH_O, _io_FileIO_readinto__doc__},
static PyObject *
_io_FileIO_readinto_impl(fileio *self, Py_buffer *buffer);
static PyObject *
_io_FileIO_readinto(fileio *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
}
return_value = _io_FileIO_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
if (buffer.obj) {
PyBuffer_Release(&buffer);
}
return return_value;
}
PyDoc_STRVAR(_io_FileIO_readall__doc__,
"readall($self, /)\n"
"--\n"
"\n"
"Read all data from the file, returned as bytes.\n"
"\n"
"In non-blocking mode, returns as much as is immediately available,\n"
"or None if no data is available. Return an empty bytes object at EOF.");
#define _IO_FILEIO_READALL_METHODDEF \
{"readall", (PyCFunction)_io_FileIO_readall, METH_NOARGS, _io_FileIO_readall__doc__},
static PyObject *
_io_FileIO_readall_impl(fileio *self);
static PyObject *
_io_FileIO_readall(fileio *self, PyObject *Py_UNUSED(ignored))
{
return _io_FileIO_readall_impl(self);
}
PyDoc_STRVAR(_io_FileIO_read__doc__,
"read($self, size=-1, /)\n"
"--\n"
"\n"
"Read at most size bytes, returned as bytes.\n"
"\n"
"Only makes one system call, so less data may be returned than requested.\n"
"In non-blocking mode, returns None if no data is available.\n"
"Return an empty bytes object at EOF.");
#define _IO_FILEIO_READ_METHODDEF \
{"read", (PyCFunction)_io_FileIO_read, METH_VARARGS, _io_FileIO_read__doc__},
static PyObject *
_io_FileIO_read_impl(fileio *self, Py_ssize_t size);
static PyObject *
_io_FileIO_read(fileio *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_ssize_t size = -1;
if (!PyArg_ParseTuple(args, "|O&:read",
_PyIO_ConvertSsize_t, &size)) {
goto exit;
}
return_value = _io_FileIO_read_impl(self, size);
exit:
return return_value;
}
PyDoc_STRVAR(_io_FileIO_write__doc__,
"write($self, b, /)\n"
"--\n"
"\n"
"Write buffer b to file, return number of bytes written.\n"
"\n"
"Only makes one system call, so not all of the data may be written.\n"
"The number of bytes actually written is returned. In non-blocking mode,\n"
"returns None if the write would block.");
#define _IO_FILEIO_WRITE_METHODDEF \
{"write", (PyCFunction)_io_FileIO_write, METH_O, _io_FileIO_write__doc__},
static PyObject *
_io_FileIO_write_impl(fileio *self, Py_buffer *b);
static PyObject *
_io_FileIO_write(fileio *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer b = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:write", &b)) {
goto exit;
}
return_value = _io_FileIO_write_impl(self, &b);
exit:
/* Cleanup for b */
if (b.obj) {
PyBuffer_Release(&b);
}
return return_value;
}
PyDoc_STRVAR(_io_FileIO_seek__doc__,
"seek($self, pos, whence=0, /)\n"
"--\n"
"\n"
"Move to new file position and return the file position.\n"
"\n"
"Argument offset is a byte count. Optional argument whence defaults to\n"
"SEEK_SET or 0 (offset from start of file, offset should be >= 0); other values\n"
"are SEEK_CUR or 1 (move relative to current position, positive or negative),\n"
"and SEEK_END or 2 (move relative to end of file, usually negative, although\n"
"many platforms allow seeking beyond the end of a file).\n"
"\n"
"Note that not all file objects are seekable.");
#define _IO_FILEIO_SEEK_METHODDEF \
{"seek", (PyCFunction)_io_FileIO_seek, METH_VARARGS, _io_FileIO_seek__doc__},
static PyObject *
_io_FileIO_seek_impl(fileio *self, PyObject *pos, int whence);
static PyObject *
_io_FileIO_seek(fileio *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *pos;
int whence = 0;
if (!PyArg_ParseTuple(args, "O|i:seek",
&pos, &whence)) {
goto exit;
}
return_value = _io_FileIO_seek_impl(self, pos, whence);
exit:
return return_value;
}
PyDoc_STRVAR(_io_FileIO_tell__doc__,
"tell($self, /)\n"
"--\n"
"\n"
"Current file position.\n"
"\n"
"Can raise OSError for non seekable files.");
#define _IO_FILEIO_TELL_METHODDEF \
{"tell", (PyCFunction)_io_FileIO_tell, METH_NOARGS, _io_FileIO_tell__doc__},
static PyObject *
_io_FileIO_tell_impl(fileio *self);
static PyObject *
_io_FileIO_tell(fileio *self, PyObject *Py_UNUSED(ignored))
{
return _io_FileIO_tell_impl(self);
}
#if defined(HAVE_FTRUNCATE)
PyDoc_STRVAR(_io_FileIO_truncate__doc__,
"truncate($self, size=None, /)\n"
"--\n"
"\n"
"Truncate the file to at most size bytes and return the truncated size.\n"
"\n"
"Size defaults to the current file position, as returned by tell().\n"
"The current file position is changed to the value of size.");
#define _IO_FILEIO_TRUNCATE_METHODDEF \
{"truncate", (PyCFunction)_io_FileIO_truncate, METH_VARARGS, _io_FileIO_truncate__doc__},
static PyObject *
_io_FileIO_truncate_impl(fileio *self, PyObject *posobj);
static PyObject *
_io_FileIO_truncate(fileio *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *posobj = NULL;
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
&posobj)) {
goto exit;
}
return_value = _io_FileIO_truncate_impl(self, posobj);
exit:
return return_value;
}
#endif /* defined(HAVE_FTRUNCATE) */
PyDoc_STRVAR(_io_FileIO_isatty__doc__,
"isatty($self, /)\n"
"--\n"
"\n"
"True if the file is connected to a TTY device.");
#define _IO_FILEIO_ISATTY_METHODDEF \
{"isatty", (PyCFunction)_io_FileIO_isatty, METH_NOARGS, _io_FileIO_isatty__doc__},
static PyObject *
_io_FileIO_isatty_impl(fileio *self);
static PyObject *
_io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
{
return _io_FileIO_isatty_impl(self);
}
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
#define _IO_FILEIO_TRUNCATE_METHODDEF
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
/*[clinic end generated code: output=51924bc0ee11d58e input=a9049054013a1b77]*/

View file

@ -0,0 +1,282 @@
/*[clinic input]
preserve
[clinic start generated code]*/
PyDoc_STRVAR(_io__IOBase_tell__doc__,
"tell($self, /)\n"
"--\n"
"\n"
"Return current stream position.");
#define _IO__IOBASE_TELL_METHODDEF \
{"tell", (PyCFunction)_io__IOBase_tell, METH_NOARGS, _io__IOBase_tell__doc__},
static PyObject *
_io__IOBase_tell_impl(PyObject *self);
static PyObject *
_io__IOBase_tell(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__IOBase_tell_impl(self);
}
PyDoc_STRVAR(_io__IOBase_flush__doc__,
"flush($self, /)\n"
"--\n"
"\n"
"Flush write buffers, if applicable.\n"
"\n"
"This is not implemented for read-only and non-blocking streams.");
#define _IO__IOBASE_FLUSH_METHODDEF \
{"flush", (PyCFunction)_io__IOBase_flush, METH_NOARGS, _io__IOBase_flush__doc__},
static PyObject *
_io__IOBase_flush_impl(PyObject *self);
static PyObject *
_io__IOBase_flush(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__IOBase_flush_impl(self);
}
PyDoc_STRVAR(_io__IOBase_close__doc__,
"close($self, /)\n"
"--\n"
"\n"
"Flush and close the IO object.\n"
"\n"
"This method has no effect if the file is already closed.");
#define _IO__IOBASE_CLOSE_METHODDEF \
{"close", (PyCFunction)_io__IOBase_close, METH_NOARGS, _io__IOBase_close__doc__},
static PyObject *
_io__IOBase_close_impl(PyObject *self);
static PyObject *
_io__IOBase_close(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__IOBase_close_impl(self);
}
PyDoc_STRVAR(_io__IOBase_seekable__doc__,
"seekable($self, /)\n"
"--\n"
"\n"
"Return whether object supports random access.\n"
"\n"
"If False, seek(), tell() and truncate() will raise OSError.\n"
"This method may need to do a test seek().");
#define _IO__IOBASE_SEEKABLE_METHODDEF \
{"seekable", (PyCFunction)_io__IOBase_seekable, METH_NOARGS, _io__IOBase_seekable__doc__},
static PyObject *
_io__IOBase_seekable_impl(PyObject *self);
static PyObject *
_io__IOBase_seekable(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__IOBase_seekable_impl(self);
}
PyDoc_STRVAR(_io__IOBase_readable__doc__,
"readable($self, /)\n"
"--\n"
"\n"
"Return whether object was opened for reading.\n"
"\n"
"If False, read() will raise OSError.");
#define _IO__IOBASE_READABLE_METHODDEF \
{"readable", (PyCFunction)_io__IOBase_readable, METH_NOARGS, _io__IOBase_readable__doc__},
static PyObject *
_io__IOBase_readable_impl(PyObject *self);
static PyObject *
_io__IOBase_readable(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__IOBase_readable_impl(self);
}
PyDoc_STRVAR(_io__IOBase_writable__doc__,
"writable($self, /)\n"
"--\n"
"\n"
"Return whether object was opened for writing.\n"
"\n"
"If False, write() will raise OSError.");
#define _IO__IOBASE_WRITABLE_METHODDEF \
{"writable", (PyCFunction)_io__IOBase_writable, METH_NOARGS, _io__IOBase_writable__doc__},
static PyObject *
_io__IOBase_writable_impl(PyObject *self);
static PyObject *
_io__IOBase_writable(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__IOBase_writable_impl(self);
}
PyDoc_STRVAR(_io__IOBase_fileno__doc__,
"fileno($self, /)\n"
"--\n"
"\n"
"Returns underlying file descriptor if one exists.\n"
"\n"
"OSError is raised if the IO object does not use a file descriptor.");
#define _IO__IOBASE_FILENO_METHODDEF \
{"fileno", (PyCFunction)_io__IOBase_fileno, METH_NOARGS, _io__IOBase_fileno__doc__},
static PyObject *
_io__IOBase_fileno_impl(PyObject *self);
static PyObject *
_io__IOBase_fileno(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__IOBase_fileno_impl(self);
}
PyDoc_STRVAR(_io__IOBase_isatty__doc__,
"isatty($self, /)\n"
"--\n"
"\n"
"Return whether this is an \'interactive\' stream.\n"
"\n"
"Return False if it can\'t be determined.");
#define _IO__IOBASE_ISATTY_METHODDEF \
{"isatty", (PyCFunction)_io__IOBase_isatty, METH_NOARGS, _io__IOBase_isatty__doc__},
static PyObject *
_io__IOBase_isatty_impl(PyObject *self);
static PyObject *
_io__IOBase_isatty(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__IOBase_isatty_impl(self);
}
PyDoc_STRVAR(_io__IOBase_readline__doc__,
"readline($self, size=-1, /)\n"
"--\n"
"\n"
"Read and return a line from the stream.\n"
"\n"
"If size is specified, at most size bytes will be read.\n"
"\n"
"The line terminator is always b\'\\n\' for binary files; for text\n"
"files, the newlines argument to open can be used to select the line\n"
"terminator(s) recognized.");
#define _IO__IOBASE_READLINE_METHODDEF \
{"readline", (PyCFunction)_io__IOBase_readline, METH_VARARGS, _io__IOBase_readline__doc__},
static PyObject *
_io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit);
static PyObject *
_io__IOBase_readline(PyObject *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_ssize_t limit = -1;
if (!PyArg_ParseTuple(args, "|O&:readline",
_PyIO_ConvertSsize_t, &limit)) {
goto exit;
}
return_value = _io__IOBase_readline_impl(self, limit);
exit:
return return_value;
}
PyDoc_STRVAR(_io__IOBase_readlines__doc__,
"readlines($self, hint=-1, /)\n"
"--\n"
"\n"
"Return a list of lines from the stream.\n"
"\n"
"hint can be specified to control the number of lines read: no more\n"
"lines will be read if the total size (in bytes/characters) of all\n"
"lines so far exceeds hint.");
#define _IO__IOBASE_READLINES_METHODDEF \
{"readlines", (PyCFunction)_io__IOBase_readlines, METH_VARARGS, _io__IOBase_readlines__doc__},
static PyObject *
_io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint);
static PyObject *
_io__IOBase_readlines(PyObject *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_ssize_t hint = -1;
if (!PyArg_ParseTuple(args, "|O&:readlines",
_PyIO_ConvertSsize_t, &hint)) {
goto exit;
}
return_value = _io__IOBase_readlines_impl(self, hint);
exit:
return return_value;
}
PyDoc_STRVAR(_io__IOBase_writelines__doc__,
"writelines($self, lines, /)\n"
"--\n"
"\n");
#define _IO__IOBASE_WRITELINES_METHODDEF \
{"writelines", (PyCFunction)_io__IOBase_writelines, METH_O, _io__IOBase_writelines__doc__},
PyDoc_STRVAR(_io__RawIOBase_read__doc__,
"read($self, size=-1, /)\n"
"--\n"
"\n");
#define _IO__RAWIOBASE_READ_METHODDEF \
{"read", (PyCFunction)_io__RawIOBase_read, METH_VARARGS, _io__RawIOBase_read__doc__},
static PyObject *
_io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n);
static PyObject *
_io__RawIOBase_read(PyObject *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_ssize_t n = -1;
if (!PyArg_ParseTuple(args, "|n:read",
&n)) {
goto exit;
}
return_value = _io__RawIOBase_read_impl(self, n);
exit:
return return_value;
}
PyDoc_STRVAR(_io__RawIOBase_readall__doc__,
"readall($self, /)\n"
"--\n"
"\n"
"Read until EOF, using multiple read() call.");
#define _IO__RAWIOBASE_READALL_METHODDEF \
{"readall", (PyCFunction)_io__RawIOBase_readall, METH_NOARGS, _io__RawIOBase_readall__doc__},
static PyObject *
_io__RawIOBase_readall_impl(PyObject *self);
static PyObject *
_io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__RawIOBase_readall_impl(self);
}
/*[clinic end generated code: output=0f53fed928d8e02f input=a9049054013a1b77]*/

View file

@ -0,0 +1,292 @@
/*[clinic input]
preserve
[clinic start generated code]*/
PyDoc_STRVAR(_io_StringIO_getvalue__doc__,
"getvalue($self, /)\n"
"--\n"
"\n"
"Retrieve the entire contents of the object.");
#define _IO_STRINGIO_GETVALUE_METHODDEF \
{"getvalue", (PyCFunction)_io_StringIO_getvalue, METH_NOARGS, _io_StringIO_getvalue__doc__},
static PyObject *
_io_StringIO_getvalue_impl(stringio *self);
static PyObject *
_io_StringIO_getvalue(stringio *self, PyObject *Py_UNUSED(ignored))
{
return _io_StringIO_getvalue_impl(self);
}
PyDoc_STRVAR(_io_StringIO_tell__doc__,
"tell($self, /)\n"
"--\n"
"\n"
"Tell the current file position.");
#define _IO_STRINGIO_TELL_METHODDEF \
{"tell", (PyCFunction)_io_StringIO_tell, METH_NOARGS, _io_StringIO_tell__doc__},
static PyObject *
_io_StringIO_tell_impl(stringio *self);
static PyObject *
_io_StringIO_tell(stringio *self, PyObject *Py_UNUSED(ignored))
{
return _io_StringIO_tell_impl(self);
}
PyDoc_STRVAR(_io_StringIO_read__doc__,
"read($self, size=None, /)\n"
"--\n"
"\n"
"Read at most size characters, returned as a string.\n"
"\n"
"If the argument is negative or omitted, read until EOF\n"
"is reached. Return an empty string at EOF.");
#define _IO_STRINGIO_READ_METHODDEF \
{"read", (PyCFunction)_io_StringIO_read, METH_VARARGS, _io_StringIO_read__doc__},
static PyObject *
_io_StringIO_read_impl(stringio *self, PyObject *arg);
static PyObject *
_io_StringIO_read(stringio *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *arg = Py_None;
if (!PyArg_UnpackTuple(args, "read",
0, 1,
&arg)) {
goto exit;
}
return_value = _io_StringIO_read_impl(self, arg);
exit:
return return_value;
}
PyDoc_STRVAR(_io_StringIO_readline__doc__,
"readline($self, size=None, /)\n"
"--\n"
"\n"
"Read until newline or EOF.\n"
"\n"
"Returns an empty string if EOF is hit immediately.");
#define _IO_STRINGIO_READLINE_METHODDEF \
{"readline", (PyCFunction)_io_StringIO_readline, METH_VARARGS, _io_StringIO_readline__doc__},
static PyObject *
_io_StringIO_readline_impl(stringio *self, PyObject *arg);
static PyObject *
_io_StringIO_readline(stringio *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *arg = Py_None;
if (!PyArg_UnpackTuple(args, "readline",
0, 1,
&arg)) {
goto exit;
}
return_value = _io_StringIO_readline_impl(self, arg);
exit:
return return_value;
}
PyDoc_STRVAR(_io_StringIO_truncate__doc__,
"truncate($self, pos=None, /)\n"
"--\n"
"\n"
"Truncate size to pos.\n"
"\n"
"The pos argument defaults to the current file position, as\n"
"returned by tell(). The current file position is unchanged.\n"
"Returns the new absolute position.");
#define _IO_STRINGIO_TRUNCATE_METHODDEF \
{"truncate", (PyCFunction)_io_StringIO_truncate, METH_VARARGS, _io_StringIO_truncate__doc__},
static PyObject *
_io_StringIO_truncate_impl(stringio *self, PyObject *arg);
static PyObject *
_io_StringIO_truncate(stringio *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *arg = Py_None;
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
&arg)) {
goto exit;
}
return_value = _io_StringIO_truncate_impl(self, arg);
exit:
return return_value;
}
PyDoc_STRVAR(_io_StringIO_seek__doc__,
"seek($self, pos, whence=0, /)\n"
"--\n"
"\n"
"Change stream position.\n"
"\n"
"Seek to character offset pos relative to position indicated by whence:\n"
" 0 Start of stream (the default). pos should be >= 0;\n"
" 1 Current position - pos must be 0;\n"
" 2 End of stream - pos must be 0.\n"
"Returns the new absolute position.");
#define _IO_STRINGIO_SEEK_METHODDEF \
{"seek", (PyCFunction)_io_StringIO_seek, METH_VARARGS, _io_StringIO_seek__doc__},
static PyObject *
_io_StringIO_seek_impl(stringio *self, Py_ssize_t pos, int whence);
static PyObject *
_io_StringIO_seek(stringio *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_ssize_t pos;
int whence = 0;
if (!PyArg_ParseTuple(args, "n|i:seek",
&pos, &whence)) {
goto exit;
}
return_value = _io_StringIO_seek_impl(self, pos, whence);
exit:
return return_value;
}
PyDoc_STRVAR(_io_StringIO_write__doc__,
"write($self, s, /)\n"
"--\n"
"\n"
"Write string to file.\n"
"\n"
"Returns the number of characters written, which is always equal to\n"
"the length of the string.");
#define _IO_STRINGIO_WRITE_METHODDEF \
{"write", (PyCFunction)_io_StringIO_write, METH_O, _io_StringIO_write__doc__},
PyDoc_STRVAR(_io_StringIO_close__doc__,
"close($self, /)\n"
"--\n"
"\n"
"Close the IO object.\n"
"\n"
"Attempting any further operation after the object is closed\n"
"will raise a ValueError.\n"
"\n"
"This method has no effect if the file is already closed.");
#define _IO_STRINGIO_CLOSE_METHODDEF \
{"close", (PyCFunction)_io_StringIO_close, METH_NOARGS, _io_StringIO_close__doc__},
static PyObject *
_io_StringIO_close_impl(stringio *self);
static PyObject *
_io_StringIO_close(stringio *self, PyObject *Py_UNUSED(ignored))
{
return _io_StringIO_close_impl(self);
}
PyDoc_STRVAR(_io_StringIO___init____doc__,
"StringIO(initial_value=\'\', newline=\'\\n\')\n"
"--\n"
"\n"
"Text I/O implementation using an in-memory buffer.\n"
"\n"
"The initial_value argument sets the value of object. The newline\n"
"argument is like the one of TextIOWrapper\'s constructor.");
static int
_io_StringIO___init___impl(stringio *self, PyObject *value,
PyObject *newline_obj);
static int
_io_StringIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
static const char * const _keywords[] = {"initial_value", "newline", NULL};
static _PyArg_Parser _parser = {"|OO:StringIO", _keywords, 0};
PyObject *value = NULL;
PyObject *newline_obj = NULL;
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&value, &newline_obj)) {
goto exit;
}
return_value = _io_StringIO___init___impl((stringio *)self, value, newline_obj);
exit:
return return_value;
}
PyDoc_STRVAR(_io_StringIO_readable__doc__,
"readable($self, /)\n"
"--\n"
"\n"
"Returns True if the IO object can be read.");
#define _IO_STRINGIO_READABLE_METHODDEF \
{"readable", (PyCFunction)_io_StringIO_readable, METH_NOARGS, _io_StringIO_readable__doc__},
static PyObject *
_io_StringIO_readable_impl(stringio *self);
static PyObject *
_io_StringIO_readable(stringio *self, PyObject *Py_UNUSED(ignored))
{
return _io_StringIO_readable_impl(self);
}
PyDoc_STRVAR(_io_StringIO_writable__doc__,
"writable($self, /)\n"
"--\n"
"\n"
"Returns True if the IO object can be written.");
#define _IO_STRINGIO_WRITABLE_METHODDEF \
{"writable", (PyCFunction)_io_StringIO_writable, METH_NOARGS, _io_StringIO_writable__doc__},
static PyObject *
_io_StringIO_writable_impl(stringio *self);
static PyObject *
_io_StringIO_writable(stringio *self, PyObject *Py_UNUSED(ignored))
{
return _io_StringIO_writable_impl(self);
}
PyDoc_STRVAR(_io_StringIO_seekable__doc__,
"seekable($self, /)\n"
"--\n"
"\n"
"Returns True if the IO object can be seeked.");
#define _IO_STRINGIO_SEEKABLE_METHODDEF \
{"seekable", (PyCFunction)_io_StringIO_seekable, METH_NOARGS, _io_StringIO_seekable__doc__},
static PyObject *
_io_StringIO_seekable_impl(stringio *self);
static PyObject *
_io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
{
return _io_StringIO_seekable_impl(self);
}
/*[clinic end generated code: output=5dd5c2a213e75405 input=a9049054013a1b77]*/

View file

@ -0,0 +1,467 @@
/*[clinic input]
preserve
[clinic start generated code]*/
PyDoc_STRVAR(_io_IncrementalNewlineDecoder___init____doc__,
"IncrementalNewlineDecoder(decoder, translate, errors=\'strict\')\n"
"--\n"
"\n"
"Codec used when reading a file in universal newlines mode.\n"
"\n"
"It wraps another incremental decoder, translating \\r\\n and \\r into \\n.\n"
"It also records the types of newlines encountered. When used with\n"
"translate=False, it ensures that the newline sequence is returned in\n"
"one piece. When used with decoder=None, it expects unicode strings as\n"
"decode input and translates newlines without first invoking an external\n"
"decoder.");
static int
_io_IncrementalNewlineDecoder___init___impl(nldecoder_object *self,
PyObject *decoder, int translate,
PyObject *errors);
static int
_io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
static const char * const _keywords[] = {"decoder", "translate", "errors", NULL};
static _PyArg_Parser _parser = {"Oi|O:IncrementalNewlineDecoder", _keywords, 0};
PyObject *decoder;
int translate;
PyObject *errors = NULL;
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&decoder, &translate, &errors)) {
goto exit;
}
return_value = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors);
exit:
return return_value;
}
PyDoc_STRVAR(_io_IncrementalNewlineDecoder_decode__doc__,
"decode($self, /, input, final=False)\n"
"--\n"
"\n");
#define _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF \
{"decode", (PyCFunction)_io_IncrementalNewlineDecoder_decode, METH_FASTCALL, _io_IncrementalNewlineDecoder_decode__doc__},
static PyObject *
_io_IncrementalNewlineDecoder_decode_impl(nldecoder_object *self,
PyObject *input, int final);
static PyObject *
_io_IncrementalNewlineDecoder_decode(nldecoder_object *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"input", "final", NULL};
static _PyArg_Parser _parser = {"O|i:decode", _keywords, 0};
PyObject *input;
int final = 0;
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
&input, &final)) {
goto exit;
}
return_value = _io_IncrementalNewlineDecoder_decode_impl(self, input, final);
exit:
return return_value;
}
PyDoc_STRVAR(_io_IncrementalNewlineDecoder_getstate__doc__,
"getstate($self, /)\n"
"--\n"
"\n");
#define _IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF \
{"getstate", (PyCFunction)_io_IncrementalNewlineDecoder_getstate, METH_NOARGS, _io_IncrementalNewlineDecoder_getstate__doc__},
static PyObject *
_io_IncrementalNewlineDecoder_getstate_impl(nldecoder_object *self);
static PyObject *
_io_IncrementalNewlineDecoder_getstate(nldecoder_object *self, PyObject *Py_UNUSED(ignored))
{
return _io_IncrementalNewlineDecoder_getstate_impl(self);
}
PyDoc_STRVAR(_io_IncrementalNewlineDecoder_setstate__doc__,
"setstate($self, state, /)\n"
"--\n"
"\n");
#define _IO_INCREMENTALNEWLINEDECODER_SETSTATE_METHODDEF \
{"setstate", (PyCFunction)_io_IncrementalNewlineDecoder_setstate, METH_O, _io_IncrementalNewlineDecoder_setstate__doc__},
PyDoc_STRVAR(_io_IncrementalNewlineDecoder_reset__doc__,
"reset($self, /)\n"
"--\n"
"\n");
#define _IO_INCREMENTALNEWLINEDECODER_RESET_METHODDEF \
{"reset", (PyCFunction)_io_IncrementalNewlineDecoder_reset, METH_NOARGS, _io_IncrementalNewlineDecoder_reset__doc__},
static PyObject *
_io_IncrementalNewlineDecoder_reset_impl(nldecoder_object *self);
static PyObject *
_io_IncrementalNewlineDecoder_reset(nldecoder_object *self, PyObject *Py_UNUSED(ignored))
{
return _io_IncrementalNewlineDecoder_reset_impl(self);
}
PyDoc_STRVAR(_io_TextIOWrapper___init____doc__,
"TextIOWrapper(buffer, encoding=None, errors=None, newline=None,\n"
" line_buffering=False, write_through=False)\n"
"--\n"
"\n"
"Character and line based layer over a BufferedIOBase object, buffer.\n"
"\n"
"encoding gives the name of the encoding that the stream will be\n"
"decoded or encoded with. It defaults to locale.getpreferredencoding(False).\n"
"\n"
"errors determines the strictness of encoding and decoding (see\n"
"help(codecs.Codec) or the documentation for codecs.register) and\n"
"defaults to \"strict\".\n"
"\n"
"newline controls how line endings are handled. It can be None, \'\',\n"
"\'\\n\', \'\\r\', and \'\\r\\n\'. It works as follows:\n"
"\n"
"* On input, if newline is None, universal newlines mode is\n"
" enabled. Lines in the input can end in \'\\n\', \'\\r\', or \'\\r\\n\', and\n"
" these are translated into \'\\n\' before being returned to the\n"
" caller. If it is \'\', universal newline mode is enabled, but line\n"
" endings are returned to the caller untranslated. If it has any of\n"
" the other legal values, input lines are only terminated by the given\n"
" string, and the line ending is returned to the caller untranslated.\n"
"\n"
"* On output, if newline is None, any \'\\n\' characters written are\n"
" translated to the system default line separator, os.linesep. If\n"
" newline is \'\' or \'\\n\', no translation takes place. If newline is any\n"
" of the other legal values, any \'\\n\' characters written are translated\n"
" to the given string.\n"
"\n"
"If line_buffering is True, a call to flush is implied when a call to\n"
"write contains a newline character.");
static int
_io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
const char *encoding, const char *errors,
const char *newline, int line_buffering,
int write_through);
static int
_io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
static const char * const _keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL};
static _PyArg_Parser _parser = {"O|zzzii:TextIOWrapper", _keywords, 0};
PyObject *buffer;
const char *encoding = NULL;
const char *errors = NULL;
const char *newline = NULL;
int line_buffering = 0;
int write_through = 0;
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&buffer, &encoding, &errors, &newline, &line_buffering, &write_through)) {
goto exit;
}
return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through);
exit:
return return_value;
}
PyDoc_STRVAR(_io_TextIOWrapper_detach__doc__,
"detach($self, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_DETACH_METHODDEF \
{"detach", (PyCFunction)_io_TextIOWrapper_detach, METH_NOARGS, _io_TextIOWrapper_detach__doc__},
static PyObject *
_io_TextIOWrapper_detach_impl(textio *self);
static PyObject *
_io_TextIOWrapper_detach(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_detach_impl(self);
}
PyDoc_STRVAR(_io_TextIOWrapper_write__doc__,
"write($self, text, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_WRITE_METHODDEF \
{"write", (PyCFunction)_io_TextIOWrapper_write, METH_O, _io_TextIOWrapper_write__doc__},
static PyObject *
_io_TextIOWrapper_write_impl(textio *self, PyObject *text);
static PyObject *
_io_TextIOWrapper_write(textio *self, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *text;
if (!PyArg_Parse(arg, "U:write", &text)) {
goto exit;
}
return_value = _io_TextIOWrapper_write_impl(self, text);
exit:
return return_value;
}
PyDoc_STRVAR(_io_TextIOWrapper_read__doc__,
"read($self, size=-1, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_READ_METHODDEF \
{"read", (PyCFunction)_io_TextIOWrapper_read, METH_VARARGS, _io_TextIOWrapper_read__doc__},
static PyObject *
_io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n);
static PyObject *
_io_TextIOWrapper_read(textio *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_ssize_t n = -1;
if (!PyArg_ParseTuple(args, "|O&:read",
_PyIO_ConvertSsize_t, &n)) {
goto exit;
}
return_value = _io_TextIOWrapper_read_impl(self, n);
exit:
return return_value;
}
PyDoc_STRVAR(_io_TextIOWrapper_readline__doc__,
"readline($self, size=-1, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_READLINE_METHODDEF \
{"readline", (PyCFunction)_io_TextIOWrapper_readline, METH_VARARGS, _io_TextIOWrapper_readline__doc__},
static PyObject *
_io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size);
static PyObject *
_io_TextIOWrapper_readline(textio *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_ssize_t size = -1;
if (!PyArg_ParseTuple(args, "|n:readline",
&size)) {
goto exit;
}
return_value = _io_TextIOWrapper_readline_impl(self, size);
exit:
return return_value;
}
PyDoc_STRVAR(_io_TextIOWrapper_seek__doc__,
"seek($self, cookie, whence=0, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_SEEK_METHODDEF \
{"seek", (PyCFunction)_io_TextIOWrapper_seek, METH_VARARGS, _io_TextIOWrapper_seek__doc__},
static PyObject *
_io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence);
static PyObject *
_io_TextIOWrapper_seek(textio *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *cookieObj;
int whence = 0;
if (!PyArg_ParseTuple(args, "O|i:seek",
&cookieObj, &whence)) {
goto exit;
}
return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence);
exit:
return return_value;
}
PyDoc_STRVAR(_io_TextIOWrapper_tell__doc__,
"tell($self, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_TELL_METHODDEF \
{"tell", (PyCFunction)_io_TextIOWrapper_tell, METH_NOARGS, _io_TextIOWrapper_tell__doc__},
static PyObject *
_io_TextIOWrapper_tell_impl(textio *self);
static PyObject *
_io_TextIOWrapper_tell(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_tell_impl(self);
}
PyDoc_STRVAR(_io_TextIOWrapper_truncate__doc__,
"truncate($self, pos=None, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_TRUNCATE_METHODDEF \
{"truncate", (PyCFunction)_io_TextIOWrapper_truncate, METH_VARARGS, _io_TextIOWrapper_truncate__doc__},
static PyObject *
_io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos);
static PyObject *
_io_TextIOWrapper_truncate(textio *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *pos = Py_None;
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
&pos)) {
goto exit;
}
return_value = _io_TextIOWrapper_truncate_impl(self, pos);
exit:
return return_value;
}
PyDoc_STRVAR(_io_TextIOWrapper_fileno__doc__,
"fileno($self, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_FILENO_METHODDEF \
{"fileno", (PyCFunction)_io_TextIOWrapper_fileno, METH_NOARGS, _io_TextIOWrapper_fileno__doc__},
static PyObject *
_io_TextIOWrapper_fileno_impl(textio *self);
static PyObject *
_io_TextIOWrapper_fileno(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_fileno_impl(self);
}
PyDoc_STRVAR(_io_TextIOWrapper_seekable__doc__,
"seekable($self, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_SEEKABLE_METHODDEF \
{"seekable", (PyCFunction)_io_TextIOWrapper_seekable, METH_NOARGS, _io_TextIOWrapper_seekable__doc__},
static PyObject *
_io_TextIOWrapper_seekable_impl(textio *self);
static PyObject *
_io_TextIOWrapper_seekable(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_seekable_impl(self);
}
PyDoc_STRVAR(_io_TextIOWrapper_readable__doc__,
"readable($self, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_READABLE_METHODDEF \
{"readable", (PyCFunction)_io_TextIOWrapper_readable, METH_NOARGS, _io_TextIOWrapper_readable__doc__},
static PyObject *
_io_TextIOWrapper_readable_impl(textio *self);
static PyObject *
_io_TextIOWrapper_readable(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_readable_impl(self);
}
PyDoc_STRVAR(_io_TextIOWrapper_writable__doc__,
"writable($self, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_WRITABLE_METHODDEF \
{"writable", (PyCFunction)_io_TextIOWrapper_writable, METH_NOARGS, _io_TextIOWrapper_writable__doc__},
static PyObject *
_io_TextIOWrapper_writable_impl(textio *self);
static PyObject *
_io_TextIOWrapper_writable(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_writable_impl(self);
}
PyDoc_STRVAR(_io_TextIOWrapper_isatty__doc__,
"isatty($self, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_ISATTY_METHODDEF \
{"isatty", (PyCFunction)_io_TextIOWrapper_isatty, METH_NOARGS, _io_TextIOWrapper_isatty__doc__},
static PyObject *
_io_TextIOWrapper_isatty_impl(textio *self);
static PyObject *
_io_TextIOWrapper_isatty(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_isatty_impl(self);
}
PyDoc_STRVAR(_io_TextIOWrapper_flush__doc__,
"flush($self, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_FLUSH_METHODDEF \
{"flush", (PyCFunction)_io_TextIOWrapper_flush, METH_NOARGS, _io_TextIOWrapper_flush__doc__},
static PyObject *
_io_TextIOWrapper_flush_impl(textio *self);
static PyObject *
_io_TextIOWrapper_flush(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_flush_impl(self);
}
PyDoc_STRVAR(_io_TextIOWrapper_close__doc__,
"close($self, /)\n"
"--\n"
"\n");
#define _IO_TEXTIOWRAPPER_CLOSE_METHODDEF \
{"close", (PyCFunction)_io_TextIOWrapper_close, METH_NOARGS, _io_TextIOWrapper_close__doc__},
static PyObject *
_io_TextIOWrapper_close_impl(textio *self);
static PyObject *
_io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_close_impl(self);
}
/*[clinic end generated code: output=78ad14eba1667254 input=a9049054013a1b77]*/

View file

@ -0,0 +1,331 @@
/*[clinic input]
preserve
[clinic start generated code]*/
#if defined(MS_WINDOWS)
PyDoc_STRVAR(_io__WindowsConsoleIO_close__doc__,
"close($self, /)\n"
"--\n"
"\n"
"Close the handle.\n"
"\n"
"A closed handle cannot be used for further I/O operations. close() may be\n"
"called more than once without error.");
#define _IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF \
{"close", (PyCFunction)_io__WindowsConsoleIO_close, METH_NOARGS, _io__WindowsConsoleIO_close__doc__},
static PyObject *
_io__WindowsConsoleIO_close_impl(winconsoleio *self);
static PyObject *
_io__WindowsConsoleIO_close(winconsoleio *self, PyObject *Py_UNUSED(ignored))
{
return _io__WindowsConsoleIO_close_impl(self);
}
#endif /* defined(MS_WINDOWS) */
#if defined(MS_WINDOWS)
PyDoc_STRVAR(_io__WindowsConsoleIO___init____doc__,
"_WindowsConsoleIO(file, mode=\'r\', closefd=True, opener=None)\n"
"--\n"
"\n"
"Open a console buffer by file descriptor.\n"
"\n"
"The mode can be \'rb\' (default), or \'wb\' for reading or writing bytes. All\n"
"other mode characters will be ignored. Mode \'b\' will be assumed if it is\n"
"omitted. The *opener* parameter is always ignored.");
static int
_io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
const char *mode, int closefd,
PyObject *opener);
static int
_io__WindowsConsoleIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
static const char * const _keywords[] = {"file", "mode", "closefd", "opener", NULL};
static _PyArg_Parser _parser = {"O|siO:_WindowsConsoleIO", _keywords, 0};
PyObject *nameobj;
const char *mode = "r";
int closefd = 1;
PyObject *opener = Py_None;
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&nameobj, &mode, &closefd, &opener)) {
goto exit;
}
return_value = _io__WindowsConsoleIO___init___impl((winconsoleio *)self, nameobj, mode, closefd, opener);
exit:
return return_value;
}
#endif /* defined(MS_WINDOWS) */
#if defined(MS_WINDOWS)
PyDoc_STRVAR(_io__WindowsConsoleIO_fileno__doc__,
"fileno($self, /)\n"
"--\n"
"\n"
"Return the underlying file descriptor (an integer).\n"
"\n"
"fileno is only set when a file descriptor is used to open\n"
"one of the standard streams.");
#define _IO__WINDOWSCONSOLEIO_FILENO_METHODDEF \
{"fileno", (PyCFunction)_io__WindowsConsoleIO_fileno, METH_NOARGS, _io__WindowsConsoleIO_fileno__doc__},
static PyObject *
_io__WindowsConsoleIO_fileno_impl(winconsoleio *self);
static PyObject *
_io__WindowsConsoleIO_fileno(winconsoleio *self, PyObject *Py_UNUSED(ignored))
{
return _io__WindowsConsoleIO_fileno_impl(self);
}
#endif /* defined(MS_WINDOWS) */
#if defined(MS_WINDOWS)
PyDoc_STRVAR(_io__WindowsConsoleIO_readable__doc__,
"readable($self, /)\n"
"--\n"
"\n"
"True if console is an input buffer.");
#define _IO__WINDOWSCONSOLEIO_READABLE_METHODDEF \
{"readable", (PyCFunction)_io__WindowsConsoleIO_readable, METH_NOARGS, _io__WindowsConsoleIO_readable__doc__},
static PyObject *
_io__WindowsConsoleIO_readable_impl(winconsoleio *self);
static PyObject *
_io__WindowsConsoleIO_readable(winconsoleio *self, PyObject *Py_UNUSED(ignored))
{
return _io__WindowsConsoleIO_readable_impl(self);
}
#endif /* defined(MS_WINDOWS) */
#if defined(MS_WINDOWS)
PyDoc_STRVAR(_io__WindowsConsoleIO_writable__doc__,
"writable($self, /)\n"
"--\n"
"\n"
"True if console is an output buffer.");
#define _IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF \
{"writable", (PyCFunction)_io__WindowsConsoleIO_writable, METH_NOARGS, _io__WindowsConsoleIO_writable__doc__},
static PyObject *
_io__WindowsConsoleIO_writable_impl(winconsoleio *self);
static PyObject *
_io__WindowsConsoleIO_writable(winconsoleio *self, PyObject *Py_UNUSED(ignored))
{
return _io__WindowsConsoleIO_writable_impl(self);
}
#endif /* defined(MS_WINDOWS) */
#if defined(MS_WINDOWS)
PyDoc_STRVAR(_io__WindowsConsoleIO_readinto__doc__,
"readinto($self, buffer, /)\n"
"--\n"
"\n"
"Same as RawIOBase.readinto().");
#define _IO__WINDOWSCONSOLEIO_READINTO_METHODDEF \
{"readinto", (PyCFunction)_io__WindowsConsoleIO_readinto, METH_O, _io__WindowsConsoleIO_readinto__doc__},
static PyObject *
_io__WindowsConsoleIO_readinto_impl(winconsoleio *self, Py_buffer *buffer);
static PyObject *
_io__WindowsConsoleIO_readinto(winconsoleio *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
}
return_value = _io__WindowsConsoleIO_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
if (buffer.obj) {
PyBuffer_Release(&buffer);
}
return return_value;
}
#endif /* defined(MS_WINDOWS) */
#if defined(MS_WINDOWS)
PyDoc_STRVAR(_io__WindowsConsoleIO_readall__doc__,
"readall($self, /)\n"
"--\n"
"\n"
"Read all data from the console, returned as bytes.\n"
"\n"
"Return an empty bytes object at EOF.");
#define _IO__WINDOWSCONSOLEIO_READALL_METHODDEF \
{"readall", (PyCFunction)_io__WindowsConsoleIO_readall, METH_NOARGS, _io__WindowsConsoleIO_readall__doc__},
static PyObject *
_io__WindowsConsoleIO_readall_impl(winconsoleio *self);
static PyObject *
_io__WindowsConsoleIO_readall(winconsoleio *self, PyObject *Py_UNUSED(ignored))
{
return _io__WindowsConsoleIO_readall_impl(self);
}
#endif /* defined(MS_WINDOWS) */
#if defined(MS_WINDOWS)
PyDoc_STRVAR(_io__WindowsConsoleIO_read__doc__,
"read($self, size=-1, /)\n"
"--\n"
"\n"
"Read at most size bytes, returned as bytes.\n"
"\n"
"Only makes one system call when size is a positive integer,\n"
"so less data may be returned than requested.\n"
"Return an empty bytes object at EOF.");
#define _IO__WINDOWSCONSOLEIO_READ_METHODDEF \
{"read", (PyCFunction)_io__WindowsConsoleIO_read, METH_VARARGS, _io__WindowsConsoleIO_read__doc__},
static PyObject *
_io__WindowsConsoleIO_read_impl(winconsoleio *self, Py_ssize_t size);
static PyObject *
_io__WindowsConsoleIO_read(winconsoleio *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_ssize_t size = -1;
if (!PyArg_ParseTuple(args, "|O&:read",
_PyIO_ConvertSsize_t, &size)) {
goto exit;
}
return_value = _io__WindowsConsoleIO_read_impl(self, size);
exit:
return return_value;
}
#endif /* defined(MS_WINDOWS) */
#if defined(MS_WINDOWS)
PyDoc_STRVAR(_io__WindowsConsoleIO_write__doc__,
"write($self, b, /)\n"
"--\n"
"\n"
"Write buffer b to file, return number of bytes written.\n"
"\n"
"Only makes one system call, so not all of the data may be written.\n"
"The number of bytes actually written is returned.");
#define _IO__WINDOWSCONSOLEIO_WRITE_METHODDEF \
{"write", (PyCFunction)_io__WindowsConsoleIO_write, METH_O, _io__WindowsConsoleIO_write__doc__},
static PyObject *
_io__WindowsConsoleIO_write_impl(winconsoleio *self, Py_buffer *b);
static PyObject *
_io__WindowsConsoleIO_write(winconsoleio *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer b = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:write", &b)) {
goto exit;
}
return_value = _io__WindowsConsoleIO_write_impl(self, &b);
exit:
/* Cleanup for b */
if (b.obj) {
PyBuffer_Release(&b);
}
return return_value;
}
#endif /* defined(MS_WINDOWS) */
#if defined(MS_WINDOWS)
PyDoc_STRVAR(_io__WindowsConsoleIO_isatty__doc__,
"isatty($self, /)\n"
"--\n"
"\n"
"Always True.");
#define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF \
{"isatty", (PyCFunction)_io__WindowsConsoleIO_isatty, METH_NOARGS, _io__WindowsConsoleIO_isatty__doc__},
static PyObject *
_io__WindowsConsoleIO_isatty_impl(winconsoleio *self);
static PyObject *
_io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored))
{
return _io__WindowsConsoleIO_isatty_impl(self);
}
#endif /* defined(MS_WINDOWS) */
#ifndef _IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF
#define _IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF) */
#ifndef _IO__WINDOWSCONSOLEIO_FILENO_METHODDEF
#define _IO__WINDOWSCONSOLEIO_FILENO_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_FILENO_METHODDEF) */
#ifndef _IO__WINDOWSCONSOLEIO_READABLE_METHODDEF
#define _IO__WINDOWSCONSOLEIO_READABLE_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_READABLE_METHODDEF) */
#ifndef _IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF
#define _IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF) */
#ifndef _IO__WINDOWSCONSOLEIO_READINTO_METHODDEF
#define _IO__WINDOWSCONSOLEIO_READINTO_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_READINTO_METHODDEF) */
#ifndef _IO__WINDOWSCONSOLEIO_READALL_METHODDEF
#define _IO__WINDOWSCONSOLEIO_READALL_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_READALL_METHODDEF) */
#ifndef _IO__WINDOWSCONSOLEIO_READ_METHODDEF
#define _IO__WINDOWSCONSOLEIO_READ_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_READ_METHODDEF) */
#ifndef _IO__WINDOWSCONSOLEIO_WRITE_METHODDEF
#define _IO__WINDOWSCONSOLEIO_WRITE_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_WRITE_METHODDEF) */
#ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */
/*[clinic end generated code: output=9eba916f8537fff7 input=a9049054013a1b77]*/

1239
third_party/python/Modules/_io/fileio.c vendored Normal file

File diff suppressed because it is too large Load diff

1044
third_party/python/Modules/_io/iobase.c vendored Normal file

File diff suppressed because it is too large Load diff

1087
third_party/python/Modules/_io/stringio.c vendored Normal file

File diff suppressed because it is too large Load diff

2980
third_party/python/Modules/_io/textio.c vendored Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff