diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/tools/python3/src/Modules/_io/_iomodule.c | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Modules/_io/_iomodule.c')
-rw-r--r-- | contrib/tools/python3/src/Modules/_io/_iomodule.c | 150 |
1 files changed, 75 insertions, 75 deletions
diff --git a/contrib/tools/python3/src/Modules/_io/_iomodule.c b/contrib/tools/python3/src/Modules/_io/_iomodule.c index d7cadacea1..cb60a90e4b 100644 --- a/contrib/tools/python3/src/Modules/_io/_iomodule.c +++ b/contrib/tools/python3/src/Modules/_io/_iomodule.c @@ -101,9 +101,9 @@ _io.open file: object mode: str = "r" buffering: int = -1 - encoding: str(accept={str, NoneType}) = None - errors: str(accept={str, NoneType}) = None - newline: str(accept={str, NoneType}) = None + encoding: str(accept={str, NoneType}) = None + errors: str(accept={str, NoneType}) = None + newline: str(accept={str, NoneType}) = None closefd: bool(accept={int}) = True opener: object = None @@ -231,7 +231,7 @@ 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=7295902222e6b311]*/ +/*[clinic end generated code: output=aefafc4ce2b46dc0 input=7295902222e6b311]*/ { unsigned i; @@ -240,7 +240,7 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode, char rawmode[6], *m; int line_buffering, is_number; - long isatty = 0; + long isatty = 0; PyObject *raw, *modeobj = NULL, *buffer, *wrapper, *result = NULL, *path_or_fd = NULL; @@ -323,7 +323,7 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode, if (universal) { if (creating || writing || appending || updating) { PyErr_SetString(PyExc_ValueError, - "mode U cannot be combined with 'x', 'w', 'a', or '+'"); + "mode U cannot be combined with 'x', 'w', 'a', or '+'"); goto error; } if (PyErr_WarnEx(PyExc_DeprecationWarning, @@ -362,29 +362,29 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode, goto error; } - if (binary && buffering == 1) { - if (PyErr_WarnEx(PyExc_RuntimeWarning, - "line buffering (buffering=1) isn't supported in " - "binary mode, the default buffer size will be used", - 1) < 0) { - goto error; - } - } - + if (binary && buffering == 1) { + if (PyErr_WarnEx(PyExc_RuntimeWarning, + "line buffering (buffering=1) isn't supported in " + "binary mode, the default buffer size will be used", + 1) < 0) { + goto error; + } + } + /* Create the Raw file stream */ { PyObject *RawIO_class = (PyObject *)&PyFileIO_Type; #ifdef MS_WINDOWS - const PyConfig *config = _Py_GetConfig(); - if (!config->legacy_windows_stdio && _PyIO_get_console_type(path_or_fd) != '\0') { + const PyConfig *config = _Py_GetConfig(); + if (!config->legacy_windows_stdio && _PyIO_get_console_type(path_or_fd) != '\0') { RawIO_class = (PyObject *)&PyWindowsConsoleIO_Type; encoding = "utf-8"; } #endif - raw = PyObject_CallFunction(RawIO_class, "OsOO", - path_or_fd, rawmode, - closefd ? Py_True : Py_False, - opener); + raw = PyObject_CallFunction(RawIO_class, "OsOO", + path_or_fd, rawmode, + closefd ? Py_True : Py_False, + opener); } if (raw == NULL) @@ -399,8 +399,8 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode, goto error; /* buffering */ - if (buffering < 0) { - PyObject *res = _PyObject_CallMethodIdNoArgs(raw, &PyId_isatty); + if (buffering < 0) { + PyObject *res = _PyObject_CallMethodIdNoArgs(raw, &PyId_isatty); if (res == NULL) goto error; isatty = PyLong_AsLong(res); @@ -409,7 +409,7 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode, goto error; } - if (buffering == 1 || isatty) { + if (buffering == 1 || isatty) { buffering = -1; line_buffering = 1; } @@ -476,10 +476,10 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode, /* wraps into a TextIOWrapper */ wrapper = PyObject_CallFunction((PyObject *)&PyTextIOWrapper_Type, - "OsssO", + "OsssO", buffer, encoding, errors, newline, - line_buffering ? Py_True : Py_False); + line_buffering ? Py_True : Py_False); if (wrapper == NULL) goto error; result = wrapper; @@ -494,7 +494,7 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode, if (result != NULL) { PyObject *exc, *val, *tb, *close_result; PyErr_Fetch(&exc, &val, &tb); - close_result = _PyObject_CallMethodIdNoArgs(result, &PyId_close); + close_result = _PyObject_CallMethodIdNoArgs(result, &PyId_close); _PyErr_ChainExceptions(exc, val, tb); Py_XDECREF(close_result); Py_DECREF(result); @@ -503,25 +503,25 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode, Py_XDECREF(modeobj); return NULL; } - -/*[clinic input] -_io.open_code - - path : unicode - -Opens the provided file with the intent to import the contents. - -This may perform extra validation beyond open(), but is otherwise interchangeable -with calling open(path, 'rb'). - -[clinic start generated code]*/ - -static PyObject * -_io_open_code_impl(PyObject *module, PyObject *path) -/*[clinic end generated code: output=2fe4ecbd6f3d6844 input=f5c18e23f4b2ed9f]*/ -{ - return PyFile_OpenCodeObject(path); -} + +/*[clinic input] +_io.open_code + + path : unicode + +Opens the provided file with the intent to import the contents. + +This may perform extra validation beyond open(), but is otherwise interchangeable +with calling open(path, 'rb'). + +[clinic start generated code]*/ + +static PyObject * +_io_open_code_impl(PyObject *module, PyObject *path) +/*[clinic end generated code: output=2fe4ecbd6f3d6844 input=f5c18e23f4b2ed9f]*/ +{ + return PyFile_OpenCodeObject(path); +} /* * Private helpers for the io module. @@ -563,7 +563,7 @@ PyNumber_AsOff_t(PyObject *item, PyObject *err) /* Otherwise replace the error with caller's error object. */ PyErr_Format(err, "cannot fit '%.200s' into an offset-sized integer", - Py_TYPE(item)->tp_name); + Py_TYPE(item)->tp_name); } finish: @@ -571,20 +571,20 @@ PyNumber_AsOff_t(PyObject *item, PyObject *err) return result; } -static inline _PyIO_State* -get_io_state(PyObject *module) -{ - void *state = PyModule_GetState(module); - assert(state != NULL); - return (_PyIO_State *)state; -} +static inline _PyIO_State* +get_io_state(PyObject *module) +{ + void *state = PyModule_GetState(module); + assert(state != NULL); + return (_PyIO_State *)state; +} _PyIO_State * _PyIO_get_module_state(void) { PyObject *mod = PyState_FindModule(&_PyIO_Module); _PyIO_State *state; - if (mod == NULL || (state = get_io_state(mod)) == NULL) { + if (mod == NULL || (state = get_io_state(mod)) == NULL) { PyErr_SetString(PyExc_RuntimeError, "could not find io module state " "(interpreter shutdown?)"); @@ -620,7 +620,7 @@ _PyIO_get_locale_module(_PyIO_State *state) static int iomodule_traverse(PyObject *mod, visitproc visit, void *arg) { - _PyIO_State *state = get_io_state(mod); + _PyIO_State *state = get_io_state(mod); if (!state->initialized) return 0; if (state->locale_module != NULL) { @@ -633,7 +633,7 @@ iomodule_traverse(PyObject *mod, visitproc visit, void *arg) { static int iomodule_clear(PyObject *mod) { - _PyIO_State *state = get_io_state(mod); + _PyIO_State *state = get_io_state(mod); if (!state->initialized) return 0; if (state->locale_module != NULL) @@ -656,7 +656,7 @@ iomodule_free(PyObject *mod) { static PyMethodDef module_methods[] = { _IO_OPEN_METHODDEF - _IO_OPEN_CODE_METHODDEF + _IO_OPEN_CODE_METHODDEF {NULL, NULL} }; @@ -679,11 +679,11 @@ PyInit__io(void) _PyIO_State *state = NULL; if (m == NULL) return NULL; - state = get_io_state(m); + state = get_io_state(m); state->initialized = 0; -#define ADD_TYPE(type) \ - if (PyModule_AddType(m, type) < 0) { \ +#define ADD_TYPE(type) \ + if (PyModule_AddType(m, type) < 0) { \ goto fail; \ } @@ -711,54 +711,54 @@ PyInit__io(void) /* Concrete base types of the IO ABCs. (the ABCs themselves are declared through inheritance in io.py) */ - ADD_TYPE(&PyIOBase_Type); - ADD_TYPE(&PyRawIOBase_Type); - ADD_TYPE(&PyBufferedIOBase_Type); - ADD_TYPE(&PyTextIOBase_Type); + ADD_TYPE(&PyIOBase_Type); + ADD_TYPE(&PyRawIOBase_Type); + ADD_TYPE(&PyBufferedIOBase_Type); + ADD_TYPE(&PyTextIOBase_Type); /* Implementation of concrete IO objects. */ /* FileIO */ PyFileIO_Type.tp_base = &PyRawIOBase_Type; - ADD_TYPE(&PyFileIO_Type); + ADD_TYPE(&PyFileIO_Type); /* BytesIO */ PyBytesIO_Type.tp_base = &PyBufferedIOBase_Type; - ADD_TYPE(&PyBytesIO_Type); + ADD_TYPE(&PyBytesIO_Type); if (PyType_Ready(&_PyBytesIOBuffer_Type) < 0) goto fail; /* StringIO */ PyStringIO_Type.tp_base = &PyTextIOBase_Type; - ADD_TYPE(&PyStringIO_Type); + ADD_TYPE(&PyStringIO_Type); #ifdef MS_WINDOWS /* WindowsConsoleIO */ PyWindowsConsoleIO_Type.tp_base = &PyRawIOBase_Type; - ADD_TYPE(&PyWindowsConsoleIO_Type); + ADD_TYPE(&PyWindowsConsoleIO_Type); #endif /* BufferedReader */ PyBufferedReader_Type.tp_base = &PyBufferedIOBase_Type; - ADD_TYPE(&PyBufferedReader_Type); + ADD_TYPE(&PyBufferedReader_Type); /* BufferedWriter */ PyBufferedWriter_Type.tp_base = &PyBufferedIOBase_Type; - ADD_TYPE(&PyBufferedWriter_Type); + ADD_TYPE(&PyBufferedWriter_Type); /* BufferedRWPair */ PyBufferedRWPair_Type.tp_base = &PyBufferedIOBase_Type; - ADD_TYPE(&PyBufferedRWPair_Type); + ADD_TYPE(&PyBufferedRWPair_Type); /* BufferedRandom */ PyBufferedRandom_Type.tp_base = &PyBufferedIOBase_Type; - ADD_TYPE(&PyBufferedRandom_Type); + ADD_TYPE(&PyBufferedRandom_Type); /* TextIOWrapper */ PyTextIOWrapper_Type.tp_base = &PyTextIOBase_Type; - ADD_TYPE(&PyTextIOWrapper_Type); + ADD_TYPE(&PyTextIOWrapper_Type); /* IncrementalNewlineDecoder */ - ADD_TYPE(&PyIncrementalNewlineDecoder_Type); + ADD_TYPE(&PyIncrementalNewlineDecoder_Type); /* Interned strings */ #define ADD_INTERNED(name) \ |