1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 # include "pycore_gc.h" // PyGC_Head
7 # include "pycore_runtime.h" // _Py_ID()
8 #endif
9 #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
10
11 PyDoc_STRVAR(_csv_list_dialects__doc__,
12 "list_dialects($module, /)\n"
13 "--\n"
14 "\n"
15 "Return a list of all known dialect names.\n"
16 "\n"
17 " names = csv.list_dialects()");
18
19 #define _CSV_LIST_DIALECTS_METHODDEF \
20 {"list_dialects", (PyCFunction)_csv_list_dialects, METH_NOARGS, _csv_list_dialects__doc__},
21
22 static PyObject *
23 _csv_list_dialects_impl(PyObject *module);
24
25 static PyObject *
_csv_list_dialects(PyObject * module,PyObject * Py_UNUSED (ignored))26 _csv_list_dialects(PyObject *module, PyObject *Py_UNUSED(ignored))
27 {
28 return _csv_list_dialects_impl(module);
29 }
30
31 PyDoc_STRVAR(_csv_unregister_dialect__doc__,
32 "unregister_dialect($module, /, name)\n"
33 "--\n"
34 "\n"
35 "Delete the name/dialect mapping associated with a string name.\n"
36 "\n"
37 " csv.unregister_dialect(name)");
38
39 #define _CSV_UNREGISTER_DIALECT_METHODDEF \
40 {"unregister_dialect", _PyCFunction_CAST(_csv_unregister_dialect), METH_FASTCALL|METH_KEYWORDS, _csv_unregister_dialect__doc__},
41
42 static PyObject *
43 _csv_unregister_dialect_impl(PyObject *module, PyObject *name);
44
45 static PyObject *
_csv_unregister_dialect(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)46 _csv_unregister_dialect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
47 {
48 PyObject *return_value = NULL;
49 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
50
51 #define NUM_KEYWORDS 1
52 static struct {
53 PyGC_Head _this_is_not_used;
54 PyObject_VAR_HEAD
55 PyObject *ob_item[NUM_KEYWORDS];
56 } _kwtuple = {
57 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
58 .ob_item = { &_Py_ID(name), },
59 };
60 #undef NUM_KEYWORDS
61 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
62
63 #else // !Py_BUILD_CORE
64 # define KWTUPLE NULL
65 #endif // !Py_BUILD_CORE
66
67 static const char * const _keywords[] = {"name", NULL};
68 static _PyArg_Parser _parser = {
69 .keywords = _keywords,
70 .fname = "unregister_dialect",
71 .kwtuple = KWTUPLE,
72 };
73 #undef KWTUPLE
74 PyObject *argsbuf[1];
75 PyObject *name;
76
77 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
78 if (!args) {
79 goto exit;
80 }
81 name = args[0];
82 return_value = _csv_unregister_dialect_impl(module, name);
83
84 exit:
85 return return_value;
86 }
87
88 PyDoc_STRVAR(_csv_get_dialect__doc__,
89 "get_dialect($module, /, name)\n"
90 "--\n"
91 "\n"
92 "Return the dialect instance associated with name.\n"
93 "\n"
94 " dialect = csv.get_dialect(name)");
95
96 #define _CSV_GET_DIALECT_METHODDEF \
97 {"get_dialect", _PyCFunction_CAST(_csv_get_dialect), METH_FASTCALL|METH_KEYWORDS, _csv_get_dialect__doc__},
98
99 static PyObject *
100 _csv_get_dialect_impl(PyObject *module, PyObject *name);
101
102 static PyObject *
_csv_get_dialect(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)103 _csv_get_dialect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
104 {
105 PyObject *return_value = NULL;
106 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
107
108 #define NUM_KEYWORDS 1
109 static struct {
110 PyGC_Head _this_is_not_used;
111 PyObject_VAR_HEAD
112 PyObject *ob_item[NUM_KEYWORDS];
113 } _kwtuple = {
114 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
115 .ob_item = { &_Py_ID(name), },
116 };
117 #undef NUM_KEYWORDS
118 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
119
120 #else // !Py_BUILD_CORE
121 # define KWTUPLE NULL
122 #endif // !Py_BUILD_CORE
123
124 static const char * const _keywords[] = {"name", NULL};
125 static _PyArg_Parser _parser = {
126 .keywords = _keywords,
127 .fname = "get_dialect",
128 .kwtuple = KWTUPLE,
129 };
130 #undef KWTUPLE
131 PyObject *argsbuf[1];
132 PyObject *name;
133
134 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
135 if (!args) {
136 goto exit;
137 }
138 name = args[0];
139 return_value = _csv_get_dialect_impl(module, name);
140
141 exit:
142 return return_value;
143 }
144
145 PyDoc_STRVAR(_csv_field_size_limit__doc__,
146 "field_size_limit($module, /, new_limit=<unrepresentable>)\n"
147 "--\n"
148 "\n"
149 "Sets an upper limit on parsed fields.\n"
150 "\n"
151 " csv.field_size_limit([limit])\n"
152 "\n"
153 "Returns old limit. If limit is not given, no new limit is set and\n"
154 "the old limit is returned");
155
156 #define _CSV_FIELD_SIZE_LIMIT_METHODDEF \
157 {"field_size_limit", _PyCFunction_CAST(_csv_field_size_limit), METH_FASTCALL|METH_KEYWORDS, _csv_field_size_limit__doc__},
158
159 static PyObject *
160 _csv_field_size_limit_impl(PyObject *module, PyObject *new_limit);
161
162 static PyObject *
_csv_field_size_limit(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)163 _csv_field_size_limit(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
164 {
165 PyObject *return_value = NULL;
166 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
167
168 #define NUM_KEYWORDS 1
169 static struct {
170 PyGC_Head _this_is_not_used;
171 PyObject_VAR_HEAD
172 PyObject *ob_item[NUM_KEYWORDS];
173 } _kwtuple = {
174 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
175 .ob_item = { &_Py_ID(new_limit), },
176 };
177 #undef NUM_KEYWORDS
178 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
179
180 #else // !Py_BUILD_CORE
181 # define KWTUPLE NULL
182 #endif // !Py_BUILD_CORE
183
184 static const char * const _keywords[] = {"new_limit", NULL};
185 static _PyArg_Parser _parser = {
186 .keywords = _keywords,
187 .fname = "field_size_limit",
188 .kwtuple = KWTUPLE,
189 };
190 #undef KWTUPLE
191 PyObject *argsbuf[1];
192 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
193 PyObject *new_limit = NULL;
194
195 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
196 if (!args) {
197 goto exit;
198 }
199 if (!noptargs) {
200 goto skip_optional_pos;
201 }
202 new_limit = args[0];
203 skip_optional_pos:
204 return_value = _csv_field_size_limit_impl(module, new_limit);
205
206 exit:
207 return return_value;
208 }
209 /*[clinic end generated code: output=9ec59717f5414d8b input=a9049054013a1b77]*/
210