Debian Codegraph @

Modules/_testcapi/clinic/file.c.h

raw
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #include "pycore_modsupport.h" // _PyArg_CheckPositional()
6
7 PyDoc_STRVAR(_testcapi_pyfile_newstdprinter__doc__,
8 "pyfile_newstdprinter($module, fd, /)\n"
9 "--\n"
10 "\n");
11
12 #define _TESTCAPI_PYFILE_NEWSTDPRINTER_METHODDEF \
13 {"pyfile_newstdprinter", (PyCFunction)_testcapi_pyfile_newstdprinter, METH_O, _testcapi_pyfile_newstdprinter__doc__},
14
15 static PyObject *
16 _testcapi_pyfile_newstdprinter_impl(PyObject *module, int fd);
17
18 static PyObject *
19 _testcapi_pyfile_newstdprinter(PyObject *module, PyObject *arg)
20 {
21 PyObject *return_value = NULL;
22 int fd;
23
24 fd = PyLong_AsInt(arg);
25 if (fd == -1 && PyErr_Occurred()) {
26 goto exit;
27 }
28 return_value = _testcapi_pyfile_newstdprinter_impl(module, fd);
29
30 exit:
31 return return_value;
32 }
33
34 PyDoc_STRVAR(_testcapi_py_fopen__doc__,
35 "py_fopen($module, path, mode, /)\n"
36 "--\n"
37 "\n"
38 "Call Py_fopen(), fread(256) and Py_fclose(). Return read bytes.");
39
40 #define _TESTCAPI_PY_FOPEN_METHODDEF \
41 {"py_fopen", _PyCFunction_CAST(_testcapi_py_fopen), METH_FASTCALL, _testcapi_py_fopen__doc__},
42
43 static PyObject *
44 _testcapi_py_fopen_impl(PyObject *module, PyObject *path, const char *mode,
45 Py_ssize_t mode_length);
46
47 static PyObject *
48 _testcapi_py_fopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
49 {
50 PyObject *return_value = NULL;
51 PyObject *path;
52 const char *mode;
53 Py_ssize_t mode_length;
54
55 if (!_PyArg_ParseStack(args, nargs, "Oz#:py_fopen",
56 &path, &mode, &mode_length)) {
57 goto exit;
58 }
59 return_value = _testcapi_py_fopen_impl(module, path, mode, mode_length);
60
61 exit:
62 return return_value;
63 }
64
65 PyDoc_STRVAR(_testcapi_py_universalnewlinefgets__doc__,
66 "py_universalnewlinefgets($module, file, size, /)\n"
67 "--\n"
68 "\n"
69 "Read a line from a file using Py_UniversalNewlineFgets.");
70
71 #define _TESTCAPI_PY_UNIVERSALNEWLINEFGETS_METHODDEF \
72 {"py_universalnewlinefgets", _PyCFunction_CAST(_testcapi_py_universalnewlinefgets), METH_FASTCALL, _testcapi_py_universalnewlinefgets__doc__},
73
74 static PyObject *
75 _testcapi_py_universalnewlinefgets_impl(PyObject *module, PyObject *file,
76 int size);
77
78 static PyObject *
79 _testcapi_py_universalnewlinefgets(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
80 {
81 PyObject *return_value = NULL;
82 PyObject *file;
83 int size;
84
85 if (!_PyArg_CheckPositional("py_universalnewlinefgets", nargs, 2, 2)) {
86 goto exit;
87 }
88 file = args[0];
89 size = PyLong_AsInt(args[1]);
90 if (size == -1 && PyErr_Occurred()) {
91 goto exit;
92 }
93 return_value = _testcapi_py_universalnewlinefgets_impl(module, file, size);
94
95 exit:
96 return return_value;
97 }
98 /*[clinic end generated code: output=a5ed111054e3a0bc input=a9049054013a1b77]*/