aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Objects/fileobject.c
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/tools/python3/src/Objects/fileobject.c
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
downloadydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Objects/fileobject.c')
-rw-r--r--contrib/tools/python3/src/Objects/fileobject.c182
1 files changed, 91 insertions, 91 deletions
diff --git a/contrib/tools/python3/src/Objects/fileobject.c b/contrib/tools/python3/src/Objects/fileobject.c
index 1c6ecaf82c..f2053a9986 100644
--- a/contrib/tools/python3/src/Objects/fileobject.c
+++ b/contrib/tools/python3/src/Objects/fileobject.c
@@ -2,7 +2,7 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
-#include "pycore_runtime.h" // _PyRuntime
+#include "pycore_runtime.h" // _PyRuntime
#if defined(HAVE_GETC_UNLOCKED) && !defined(_Py_MEMORY_SANITIZER)
/* clang MemorySanitizer doesn't yet understand getc_unlocked. */
@@ -25,8 +25,8 @@
extern "C" {
#endif
-_Py_IDENTIFIER(open);
-
+_Py_IDENTIFIER(open);
+
/* External C interface */
PyObject *
@@ -35,13 +35,13 @@ PyFile_FromFd(int fd, const char *name, const char *mode, int buffering, const c
{
PyObject *io, *stream;
- /* import _io in case we are being used to open io.py */
- io = PyImport_ImportModule("_io");
+ /* import _io in case we are being used to open io.py */
+ io = PyImport_ImportModule("_io");
if (io == NULL)
return NULL;
- stream = _PyObject_CallMethodId(io, &PyId_open, "isisssO", fd, mode,
+ stream = _PyObject_CallMethodId(io, &PyId_open, "isisssO", fd, mode,
buffering, encoding, errors,
- newline, closefd ? Py_True : Py_False);
+ newline, closefd ? Py_True : Py_False);
Py_DECREF(io);
if (stream == NULL)
return NULL;
@@ -62,7 +62,7 @@ PyFile_GetLine(PyObject *f, int n)
}
if (n <= 0) {
- result = _PyObject_CallMethodIdNoArgs(f, &PyId_readline);
+ result = _PyObject_CallMethodIdNoArgs(f, &PyId_readline);
}
else {
result = _PyObject_CallMethodId(f, &PyId_readline, "i", n);
@@ -76,7 +76,7 @@ PyFile_GetLine(PyObject *f, int n)
}
if (n < 0 && result != NULL && PyBytes_Check(result)) {
- const char *s = PyBytes_AS_STRING(result);
+ const char *s = PyBytes_AS_STRING(result);
Py_ssize_t len = PyBytes_GET_SIZE(result);
if (len == 0) {
Py_DECREF(result);
@@ -85,7 +85,7 @@ PyFile_GetLine(PyObject *f, int n)
"EOF when reading a line");
}
else if (s[len-1] == '\n') {
- if (Py_REFCNT(result) == 1)
+ if (Py_REFCNT(result) == 1)
_PyBytes_Resize(&result, len-1);
else {
PyObject *v;
@@ -137,7 +137,7 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
Py_DECREF(writer);
return -1;
}
- result = PyObject_CallOneArg(writer, value);
+ result = PyObject_CallOneArg(writer, value);
Py_DECREF(value);
Py_DECREF(writer);
if (result == NULL)
@@ -186,10 +186,10 @@ PyObject_AsFileDescriptor(PyObject *o)
if (PyLong_Check(o)) {
fd = _PyLong_AsInt(o);
}
- else if (_PyObject_LookupAttrId(o, &PyId_fileno, &meth) < 0) {
- return -1;
- }
- else if (meth != NULL) {
+ else if (_PyObject_LookupAttrId(o, &PyId_fileno, &meth) < 0) {
+ return -1;
+ }
+ else if (meth != NULL) {
PyObject *fno = _PyObject_CallNoArg(meth);
Py_DECREF(meth);
if (fno == NULL)
@@ -364,9 +364,9 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
Py_ssize_t n;
int err;
- /* The function can clear the current exception */
- assert(!PyErr_Occurred());
-
+ /* The function can clear the current exception */
+ assert(!PyErr_Occurred());
+
if (self->fd < 0) {
/* fd might be invalid on Windows
* I can't raise an exception here. It may lead to an
@@ -375,11 +375,11 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
Py_RETURN_NONE;
}
- if (!PyArg_ParseTuple(args, "U", &unicode)) {
+ if (!PyArg_ParseTuple(args, "U", &unicode)) {
return NULL;
- }
+ }
- /* Encode Unicode to UTF-8/surrogateescape */
+ /* Encode Unicode to UTF-8/surrogateescape */
str = PyUnicode_AsUTF8AndSize(unicode, &n);
if (str == NULL) {
PyErr_Clear();
@@ -408,7 +408,7 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
}
static PyObject *
-stdprinter_fileno(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
+stdprinter_fileno(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
{
return PyLong_FromLong((long) self->fd);
}
@@ -421,13 +421,13 @@ stdprinter_repr(PyStdPrinter_Object *self)
}
static PyObject *
-stdprinter_noop(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
+stdprinter_noop(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
{
Py_RETURN_NONE;
}
static PyObject *
-stdprinter_isatty(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
+stdprinter_isatty(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
{
long res;
if (self->fd < 0) {
@@ -482,10 +482,10 @@ PyTypeObject PyStdPrinter_Type = {
0, /* tp_itemsize */
/* methods */
0, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
(reprfunc)stdprinter_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -519,71 +519,71 @@ PyTypeObject PyStdPrinter_Type = {
};
-/* ************************** open_code hook ***************************
- * The open_code hook allows embedders to override the method used to
- * open files that are going to be used by the runtime to execute code
- */
-
-int
-PyFile_SetOpenCodeHook(Py_OpenCodeHookFunction hook, void *userData) {
- if (Py_IsInitialized() &&
- PySys_Audit("setopencodehook", NULL) < 0) {
- return -1;
- }
-
- if (_PyRuntime.open_code_hook) {
- if (Py_IsInitialized()) {
- PyErr_SetString(PyExc_SystemError,
- "failed to change existing open_code hook");
- }
- return -1;
- }
-
- _PyRuntime.open_code_hook = hook;
- _PyRuntime.open_code_userdata = userData;
- return 0;
-}
-
-PyObject *
-PyFile_OpenCodeObject(PyObject *path)
-{
- PyObject *iomod, *f = NULL;
-
- if (!PyUnicode_Check(path)) {
- PyErr_Format(PyExc_TypeError, "'path' must be 'str', not '%.200s'",
- Py_TYPE(path)->tp_name);
- return NULL;
- }
-
- Py_OpenCodeHookFunction hook = _PyRuntime.open_code_hook;
- if (hook) {
- f = hook(path, _PyRuntime.open_code_userdata);
- } else {
- iomod = PyImport_ImportModule("_io");
- if (iomod) {
- f = _PyObject_CallMethodId(iomod, &PyId_open, "Os",
- path, "rb");
- Py_DECREF(iomod);
- }
- }
-
- return f;
-}
-
-PyObject *
-PyFile_OpenCode(const char *utf8path)
-{
- PyObject *pathobj = PyUnicode_FromString(utf8path);
- PyObject *f;
- if (!pathobj) {
- return NULL;
- }
- f = PyFile_OpenCodeObject(pathobj);
- Py_DECREF(pathobj);
- return f;
-}
-
-
+/* ************************** open_code hook ***************************
+ * The open_code hook allows embedders to override the method used to
+ * open files that are going to be used by the runtime to execute code
+ */
+
+int
+PyFile_SetOpenCodeHook(Py_OpenCodeHookFunction hook, void *userData) {
+ if (Py_IsInitialized() &&
+ PySys_Audit("setopencodehook", NULL) < 0) {
+ return -1;
+ }
+
+ if (_PyRuntime.open_code_hook) {
+ if (Py_IsInitialized()) {
+ PyErr_SetString(PyExc_SystemError,
+ "failed to change existing open_code hook");
+ }
+ return -1;
+ }
+
+ _PyRuntime.open_code_hook = hook;
+ _PyRuntime.open_code_userdata = userData;
+ return 0;
+}
+
+PyObject *
+PyFile_OpenCodeObject(PyObject *path)
+{
+ PyObject *iomod, *f = NULL;
+
+ if (!PyUnicode_Check(path)) {
+ PyErr_Format(PyExc_TypeError, "'path' must be 'str', not '%.200s'",
+ Py_TYPE(path)->tp_name);
+ return NULL;
+ }
+
+ Py_OpenCodeHookFunction hook = _PyRuntime.open_code_hook;
+ if (hook) {
+ f = hook(path, _PyRuntime.open_code_userdata);
+ } else {
+ iomod = PyImport_ImportModule("_io");
+ if (iomod) {
+ f = _PyObject_CallMethodId(iomod, &PyId_open, "Os",
+ path, "rb");
+ Py_DECREF(iomod);
+ }
+ }
+
+ return f;
+}
+
+PyObject *
+PyFile_OpenCode(const char *utf8path)
+{
+ PyObject *pathobj = PyUnicode_FromString(utf8path);
+ PyObject *f;
+ if (!pathobj) {
+ return NULL;
+ }
+ f = PyFile_OpenCodeObject(pathobj);
+ Py_DECREF(pathobj);
+ return f;
+}
+
+
#ifdef __cplusplus
}
#endif