• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_STRVAR(pysqlite_connection_cursor__doc__,
6 "cursor($self, /, factory=<unrepresentable>)\n"
7 "--\n"
8 "\n"
9 "Return a cursor for the connection.");
10 
11 #define PYSQLITE_CONNECTION_CURSOR_METHODDEF    \
12     {"cursor", (PyCFunction)(void(*)(void))pysqlite_connection_cursor, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_cursor__doc__},
13 
14 static PyObject *
15 pysqlite_connection_cursor_impl(pysqlite_Connection *self, PyObject *factory);
16 
17 static PyObject *
pysqlite_connection_cursor(pysqlite_Connection * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)18 pysqlite_connection_cursor(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
19 {
20     PyObject *return_value = NULL;
21     static const char * const _keywords[] = {"factory", NULL};
22     static _PyArg_Parser _parser = {NULL, _keywords, "cursor", 0};
23     PyObject *argsbuf[1];
24     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
25     PyObject *factory = NULL;
26 
27     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
28     if (!args) {
29         goto exit;
30     }
31     if (!noptargs) {
32         goto skip_optional_pos;
33     }
34     factory = args[0];
35 skip_optional_pos:
36     return_value = pysqlite_connection_cursor_impl(self, factory);
37 
38 exit:
39     return return_value;
40 }
41 
42 PyDoc_STRVAR(pysqlite_connection_close__doc__,
43 "close($self, /)\n"
44 "--\n"
45 "\n"
46 "Closes the connection.");
47 
48 #define PYSQLITE_CONNECTION_CLOSE_METHODDEF    \
49     {"close", (PyCFunction)pysqlite_connection_close, METH_NOARGS, pysqlite_connection_close__doc__},
50 
51 static PyObject *
52 pysqlite_connection_close_impl(pysqlite_Connection *self);
53 
54 static PyObject *
pysqlite_connection_close(pysqlite_Connection * self,PyObject * Py_UNUSED (ignored))55 pysqlite_connection_close(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
56 {
57     return pysqlite_connection_close_impl(self);
58 }
59 
60 PyDoc_STRVAR(pysqlite_connection_commit__doc__,
61 "commit($self, /)\n"
62 "--\n"
63 "\n"
64 "Commit the current transaction.");
65 
66 #define PYSQLITE_CONNECTION_COMMIT_METHODDEF    \
67     {"commit", (PyCFunction)pysqlite_connection_commit, METH_NOARGS, pysqlite_connection_commit__doc__},
68 
69 static PyObject *
70 pysqlite_connection_commit_impl(pysqlite_Connection *self);
71 
72 static PyObject *
pysqlite_connection_commit(pysqlite_Connection * self,PyObject * Py_UNUSED (ignored))73 pysqlite_connection_commit(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
74 {
75     return pysqlite_connection_commit_impl(self);
76 }
77 
78 PyDoc_STRVAR(pysqlite_connection_rollback__doc__,
79 "rollback($self, /)\n"
80 "--\n"
81 "\n"
82 "Roll back the current transaction.");
83 
84 #define PYSQLITE_CONNECTION_ROLLBACK_METHODDEF    \
85     {"rollback", (PyCFunction)pysqlite_connection_rollback, METH_NOARGS, pysqlite_connection_rollback__doc__},
86 
87 static PyObject *
88 pysqlite_connection_rollback_impl(pysqlite_Connection *self);
89 
90 static PyObject *
pysqlite_connection_rollback(pysqlite_Connection * self,PyObject * Py_UNUSED (ignored))91 pysqlite_connection_rollback(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
92 {
93     return pysqlite_connection_rollback_impl(self);
94 }
95 
96 PyDoc_STRVAR(pysqlite_connection_create_function__doc__,
97 "create_function($self, /, name, narg, func, *, deterministic=False)\n"
98 "--\n"
99 "\n"
100 "Creates a new function. Non-standard.");
101 
102 #define PYSQLITE_CONNECTION_CREATE_FUNCTION_METHODDEF    \
103     {"create_function", (PyCFunction)(void(*)(void))pysqlite_connection_create_function, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_function__doc__},
104 
105 static PyObject *
106 pysqlite_connection_create_function_impl(pysqlite_Connection *self,
107                                          const char *name, int narg,
108                                          PyObject *func, int deterministic);
109 
110 static PyObject *
pysqlite_connection_create_function(pysqlite_Connection * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)111 pysqlite_connection_create_function(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
112 {
113     PyObject *return_value = NULL;
114     static const char * const _keywords[] = {"name", "narg", "func", "deterministic", NULL};
115     static _PyArg_Parser _parser = {NULL, _keywords, "create_function", 0};
116     PyObject *argsbuf[4];
117     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;
118     const char *name;
119     int narg;
120     PyObject *func;
121     int deterministic = 0;
122 
123     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
124     if (!args) {
125         goto exit;
126     }
127     if (!PyUnicode_Check(args[0])) {
128         _PyArg_BadArgument("create_function", "argument 'name'", "str", args[0]);
129         goto exit;
130     }
131     Py_ssize_t name_length;
132     name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
133     if (name == NULL) {
134         goto exit;
135     }
136     if (strlen(name) != (size_t)name_length) {
137         PyErr_SetString(PyExc_ValueError, "embedded null character");
138         goto exit;
139     }
140     narg = _PyLong_AsInt(args[1]);
141     if (narg == -1 && PyErr_Occurred()) {
142         goto exit;
143     }
144     func = args[2];
145     if (!noptargs) {
146         goto skip_optional_kwonly;
147     }
148     deterministic = PyObject_IsTrue(args[3]);
149     if (deterministic < 0) {
150         goto exit;
151     }
152 skip_optional_kwonly:
153     return_value = pysqlite_connection_create_function_impl(self, name, narg, func, deterministic);
154 
155 exit:
156     return return_value;
157 }
158 
159 PyDoc_STRVAR(pysqlite_connection_create_aggregate__doc__,
160 "create_aggregate($self, /, name, n_arg, aggregate_class)\n"
161 "--\n"
162 "\n"
163 "Creates a new aggregate. Non-standard.");
164 
165 #define PYSQLITE_CONNECTION_CREATE_AGGREGATE_METHODDEF    \
166     {"create_aggregate", (PyCFunction)(void(*)(void))pysqlite_connection_create_aggregate, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_aggregate__doc__},
167 
168 static PyObject *
169 pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self,
170                                           const char *name, int n_arg,
171                                           PyObject *aggregate_class);
172 
173 static PyObject *
pysqlite_connection_create_aggregate(pysqlite_Connection * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)174 pysqlite_connection_create_aggregate(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
175 {
176     PyObject *return_value = NULL;
177     static const char * const _keywords[] = {"name", "n_arg", "aggregate_class", NULL};
178     static _PyArg_Parser _parser = {NULL, _keywords, "create_aggregate", 0};
179     PyObject *argsbuf[3];
180     const char *name;
181     int n_arg;
182     PyObject *aggregate_class;
183 
184     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
185     if (!args) {
186         goto exit;
187     }
188     if (!PyUnicode_Check(args[0])) {
189         _PyArg_BadArgument("create_aggregate", "argument 'name'", "str", args[0]);
190         goto exit;
191     }
192     Py_ssize_t name_length;
193     name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
194     if (name == NULL) {
195         goto exit;
196     }
197     if (strlen(name) != (size_t)name_length) {
198         PyErr_SetString(PyExc_ValueError, "embedded null character");
199         goto exit;
200     }
201     n_arg = _PyLong_AsInt(args[1]);
202     if (n_arg == -1 && PyErr_Occurred()) {
203         goto exit;
204     }
205     aggregate_class = args[2];
206     return_value = pysqlite_connection_create_aggregate_impl(self, name, n_arg, aggregate_class);
207 
208 exit:
209     return return_value;
210 }
211 
212 PyDoc_STRVAR(pysqlite_connection_set_authorizer__doc__,
213 "set_authorizer($self, /, authorizer_callback)\n"
214 "--\n"
215 "\n"
216 "Sets authorizer callback. Non-standard.");
217 
218 #define PYSQLITE_CONNECTION_SET_AUTHORIZER_METHODDEF    \
219     {"set_authorizer", (PyCFunction)(void(*)(void))pysqlite_connection_set_authorizer, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_authorizer__doc__},
220 
221 static PyObject *
222 pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,
223                                         PyObject *authorizer_cb);
224 
225 static PyObject *
pysqlite_connection_set_authorizer(pysqlite_Connection * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)226 pysqlite_connection_set_authorizer(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
227 {
228     PyObject *return_value = NULL;
229     static const char * const _keywords[] = {"authorizer_callback", NULL};
230     static _PyArg_Parser _parser = {NULL, _keywords, "set_authorizer", 0};
231     PyObject *argsbuf[1];
232     PyObject *authorizer_cb;
233 
234     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
235     if (!args) {
236         goto exit;
237     }
238     authorizer_cb = args[0];
239     return_value = pysqlite_connection_set_authorizer_impl(self, authorizer_cb);
240 
241 exit:
242     return return_value;
243 }
244 
245 PyDoc_STRVAR(pysqlite_connection_set_progress_handler__doc__,
246 "set_progress_handler($self, /, progress_handler, n)\n"
247 "--\n"
248 "\n"
249 "Sets progress handler callback. Non-standard.");
250 
251 #define PYSQLITE_CONNECTION_SET_PROGRESS_HANDLER_METHODDEF    \
252     {"set_progress_handler", (PyCFunction)(void(*)(void))pysqlite_connection_set_progress_handler, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_progress_handler__doc__},
253 
254 static PyObject *
255 pysqlite_connection_set_progress_handler_impl(pysqlite_Connection *self,
256                                               PyObject *progress_handler,
257                                               int n);
258 
259 static PyObject *
pysqlite_connection_set_progress_handler(pysqlite_Connection * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)260 pysqlite_connection_set_progress_handler(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
261 {
262     PyObject *return_value = NULL;
263     static const char * const _keywords[] = {"progress_handler", "n", NULL};
264     static _PyArg_Parser _parser = {NULL, _keywords, "set_progress_handler", 0};
265     PyObject *argsbuf[2];
266     PyObject *progress_handler;
267     int n;
268 
269     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
270     if (!args) {
271         goto exit;
272     }
273     progress_handler = args[0];
274     n = _PyLong_AsInt(args[1]);
275     if (n == -1 && PyErr_Occurred()) {
276         goto exit;
277     }
278     return_value = pysqlite_connection_set_progress_handler_impl(self, progress_handler, n);
279 
280 exit:
281     return return_value;
282 }
283 
284 PyDoc_STRVAR(pysqlite_connection_set_trace_callback__doc__,
285 "set_trace_callback($self, /, trace_callback)\n"
286 "--\n"
287 "\n"
288 "Sets a trace callback called for each SQL statement (passed as unicode).\n"
289 "\n"
290 "Non-standard.");
291 
292 #define PYSQLITE_CONNECTION_SET_TRACE_CALLBACK_METHODDEF    \
293     {"set_trace_callback", (PyCFunction)(void(*)(void))pysqlite_connection_set_trace_callback, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_trace_callback__doc__},
294 
295 static PyObject *
296 pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
297                                             PyObject *trace_callback);
298 
299 static PyObject *
pysqlite_connection_set_trace_callback(pysqlite_Connection * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)300 pysqlite_connection_set_trace_callback(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
301 {
302     PyObject *return_value = NULL;
303     static const char * const _keywords[] = {"trace_callback", NULL};
304     static _PyArg_Parser _parser = {NULL, _keywords, "set_trace_callback", 0};
305     PyObject *argsbuf[1];
306     PyObject *trace_callback;
307 
308     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
309     if (!args) {
310         goto exit;
311     }
312     trace_callback = args[0];
313     return_value = pysqlite_connection_set_trace_callback_impl(self, trace_callback);
314 
315 exit:
316     return return_value;
317 }
318 
319 #if !defined(SQLITE_OMIT_LOAD_EXTENSION)
320 
321 PyDoc_STRVAR(pysqlite_connection_enable_load_extension__doc__,
322 "enable_load_extension($self, enable, /)\n"
323 "--\n"
324 "\n"
325 "Enable dynamic loading of SQLite extension modules. Non-standard.");
326 
327 #define PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF    \
328     {"enable_load_extension", (PyCFunction)pysqlite_connection_enable_load_extension, METH_O, pysqlite_connection_enable_load_extension__doc__},
329 
330 static PyObject *
331 pysqlite_connection_enable_load_extension_impl(pysqlite_Connection *self,
332                                                int onoff);
333 
334 static PyObject *
pysqlite_connection_enable_load_extension(pysqlite_Connection * self,PyObject * arg)335 pysqlite_connection_enable_load_extension(pysqlite_Connection *self, PyObject *arg)
336 {
337     PyObject *return_value = NULL;
338     int onoff;
339 
340     onoff = _PyLong_AsInt(arg);
341     if (onoff == -1 && PyErr_Occurred()) {
342         goto exit;
343     }
344     return_value = pysqlite_connection_enable_load_extension_impl(self, onoff);
345 
346 exit:
347     return return_value;
348 }
349 
350 #endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */
351 
352 #if !defined(SQLITE_OMIT_LOAD_EXTENSION)
353 
354 PyDoc_STRVAR(pysqlite_connection_load_extension__doc__,
355 "load_extension($self, name, /)\n"
356 "--\n"
357 "\n"
358 "Load SQLite extension module. Non-standard.");
359 
360 #define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF    \
361     {"load_extension", (PyCFunction)pysqlite_connection_load_extension, METH_O, pysqlite_connection_load_extension__doc__},
362 
363 static PyObject *
364 pysqlite_connection_load_extension_impl(pysqlite_Connection *self,
365                                         const char *extension_name);
366 
367 static PyObject *
pysqlite_connection_load_extension(pysqlite_Connection * self,PyObject * arg)368 pysqlite_connection_load_extension(pysqlite_Connection *self, PyObject *arg)
369 {
370     PyObject *return_value = NULL;
371     const char *extension_name;
372 
373     if (!PyUnicode_Check(arg)) {
374         _PyArg_BadArgument("load_extension", "argument", "str", arg);
375         goto exit;
376     }
377     Py_ssize_t extension_name_length;
378     extension_name = PyUnicode_AsUTF8AndSize(arg, &extension_name_length);
379     if (extension_name == NULL) {
380         goto exit;
381     }
382     if (strlen(extension_name) != (size_t)extension_name_length) {
383         PyErr_SetString(PyExc_ValueError, "embedded null character");
384         goto exit;
385     }
386     return_value = pysqlite_connection_load_extension_impl(self, extension_name);
387 
388 exit:
389     return return_value;
390 }
391 
392 #endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */
393 
394 PyDoc_STRVAR(pysqlite_connection_execute__doc__,
395 "execute($self, sql, parameters=<unrepresentable>, /)\n"
396 "--\n"
397 "\n"
398 "Executes a SQL statement. Non-standard.");
399 
400 #define PYSQLITE_CONNECTION_EXECUTE_METHODDEF    \
401     {"execute", (PyCFunction)(void(*)(void))pysqlite_connection_execute, METH_FASTCALL, pysqlite_connection_execute__doc__},
402 
403 static PyObject *
404 pysqlite_connection_execute_impl(pysqlite_Connection *self, PyObject *sql,
405                                  PyObject *parameters);
406 
407 static PyObject *
pysqlite_connection_execute(pysqlite_Connection * self,PyObject * const * args,Py_ssize_t nargs)408 pysqlite_connection_execute(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
409 {
410     PyObject *return_value = NULL;
411     PyObject *sql;
412     PyObject *parameters = NULL;
413 
414     if (!_PyArg_CheckPositional("execute", nargs, 1, 2)) {
415         goto exit;
416     }
417     if (!PyUnicode_Check(args[0])) {
418         _PyArg_BadArgument("execute", "argument 1", "str", args[0]);
419         goto exit;
420     }
421     if (PyUnicode_READY(args[0]) == -1) {
422         goto exit;
423     }
424     sql = args[0];
425     if (nargs < 2) {
426         goto skip_optional;
427     }
428     parameters = args[1];
429 skip_optional:
430     return_value = pysqlite_connection_execute_impl(self, sql, parameters);
431 
432 exit:
433     return return_value;
434 }
435 
436 PyDoc_STRVAR(pysqlite_connection_executemany__doc__,
437 "executemany($self, sql, parameters, /)\n"
438 "--\n"
439 "\n"
440 "Repeatedly executes a SQL statement. Non-standard.");
441 
442 #define PYSQLITE_CONNECTION_EXECUTEMANY_METHODDEF    \
443     {"executemany", (PyCFunction)(void(*)(void))pysqlite_connection_executemany, METH_FASTCALL, pysqlite_connection_executemany__doc__},
444 
445 static PyObject *
446 pysqlite_connection_executemany_impl(pysqlite_Connection *self,
447                                      PyObject *sql, PyObject *parameters);
448 
449 static PyObject *
pysqlite_connection_executemany(pysqlite_Connection * self,PyObject * const * args,Py_ssize_t nargs)450 pysqlite_connection_executemany(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
451 {
452     PyObject *return_value = NULL;
453     PyObject *sql;
454     PyObject *parameters;
455 
456     if (!_PyArg_CheckPositional("executemany", nargs, 2, 2)) {
457         goto exit;
458     }
459     if (!PyUnicode_Check(args[0])) {
460         _PyArg_BadArgument("executemany", "argument 1", "str", args[0]);
461         goto exit;
462     }
463     if (PyUnicode_READY(args[0]) == -1) {
464         goto exit;
465     }
466     sql = args[0];
467     parameters = args[1];
468     return_value = pysqlite_connection_executemany_impl(self, sql, parameters);
469 
470 exit:
471     return return_value;
472 }
473 
474 PyDoc_STRVAR(pysqlite_connection_executescript__doc__,
475 "executescript($self, sql_script, /)\n"
476 "--\n"
477 "\n"
478 "Executes multiple SQL statements at once. Non-standard.");
479 
480 #define PYSQLITE_CONNECTION_EXECUTESCRIPT_METHODDEF    \
481     {"executescript", (PyCFunction)pysqlite_connection_executescript, METH_O, pysqlite_connection_executescript__doc__},
482 
483 PyDoc_STRVAR(pysqlite_connection_interrupt__doc__,
484 "interrupt($self, /)\n"
485 "--\n"
486 "\n"
487 "Abort any pending database operation. Non-standard.");
488 
489 #define PYSQLITE_CONNECTION_INTERRUPT_METHODDEF    \
490     {"interrupt", (PyCFunction)pysqlite_connection_interrupt, METH_NOARGS, pysqlite_connection_interrupt__doc__},
491 
492 static PyObject *
493 pysqlite_connection_interrupt_impl(pysqlite_Connection *self);
494 
495 static PyObject *
pysqlite_connection_interrupt(pysqlite_Connection * self,PyObject * Py_UNUSED (ignored))496 pysqlite_connection_interrupt(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
497 {
498     return pysqlite_connection_interrupt_impl(self);
499 }
500 
501 PyDoc_STRVAR(pysqlite_connection_iterdump__doc__,
502 "iterdump($self, /)\n"
503 "--\n"
504 "\n"
505 "Returns iterator to the dump of the database in an SQL text format.\n"
506 "\n"
507 "Non-standard.");
508 
509 #define PYSQLITE_CONNECTION_ITERDUMP_METHODDEF    \
510     {"iterdump", (PyCFunction)pysqlite_connection_iterdump, METH_NOARGS, pysqlite_connection_iterdump__doc__},
511 
512 static PyObject *
513 pysqlite_connection_iterdump_impl(pysqlite_Connection *self);
514 
515 static PyObject *
pysqlite_connection_iterdump(pysqlite_Connection * self,PyObject * Py_UNUSED (ignored))516 pysqlite_connection_iterdump(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
517 {
518     return pysqlite_connection_iterdump_impl(self);
519 }
520 
521 PyDoc_STRVAR(pysqlite_connection_backup__doc__,
522 "backup($self, /, target, *, pages=-1, progress=None, name=\'main\',\n"
523 "       sleep=0.25)\n"
524 "--\n"
525 "\n"
526 "Makes a backup of the database. Non-standard.");
527 
528 #define PYSQLITE_CONNECTION_BACKUP_METHODDEF    \
529     {"backup", (PyCFunction)(void(*)(void))pysqlite_connection_backup, METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_backup__doc__},
530 
531 static PyObject *
532 pysqlite_connection_backup_impl(pysqlite_Connection *self,
533                                 pysqlite_Connection *target, int pages,
534                                 PyObject *progress, const char *name,
535                                 double sleep);
536 
537 static PyObject *
pysqlite_connection_backup(pysqlite_Connection * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)538 pysqlite_connection_backup(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
539 {
540     PyObject *return_value = NULL;
541     static const char * const _keywords[] = {"target", "pages", "progress", "name", "sleep", NULL};
542     static _PyArg_Parser _parser = {NULL, _keywords, "backup", 0};
543     PyObject *argsbuf[5];
544     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
545     pysqlite_Connection *target;
546     int pages = -1;
547     PyObject *progress = Py_None;
548     const char *name = "main";
549     double sleep = 0.25;
550 
551     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
552     if (!args) {
553         goto exit;
554     }
555     if (!PyObject_TypeCheck(args[0], pysqlite_ConnectionType)) {
556         _PyArg_BadArgument("backup", "argument 'target'", (pysqlite_ConnectionType)->tp_name, args[0]);
557         goto exit;
558     }
559     target = (pysqlite_Connection *)args[0];
560     if (!noptargs) {
561         goto skip_optional_kwonly;
562     }
563     if (args[1]) {
564         pages = _PyLong_AsInt(args[1]);
565         if (pages == -1 && PyErr_Occurred()) {
566             goto exit;
567         }
568         if (!--noptargs) {
569             goto skip_optional_kwonly;
570         }
571     }
572     if (args[2]) {
573         progress = args[2];
574         if (!--noptargs) {
575             goto skip_optional_kwonly;
576         }
577     }
578     if (args[3]) {
579         if (!PyUnicode_Check(args[3])) {
580             _PyArg_BadArgument("backup", "argument 'name'", "str", args[3]);
581             goto exit;
582         }
583         Py_ssize_t name_length;
584         name = PyUnicode_AsUTF8AndSize(args[3], &name_length);
585         if (name == NULL) {
586             goto exit;
587         }
588         if (strlen(name) != (size_t)name_length) {
589             PyErr_SetString(PyExc_ValueError, "embedded null character");
590             goto exit;
591         }
592         if (!--noptargs) {
593             goto skip_optional_kwonly;
594         }
595     }
596     if (PyFloat_CheckExact(args[4])) {
597         sleep = PyFloat_AS_DOUBLE(args[4]);
598     }
599     else
600     {
601         sleep = PyFloat_AsDouble(args[4]);
602         if (sleep == -1.0 && PyErr_Occurred()) {
603             goto exit;
604         }
605     }
606 skip_optional_kwonly:
607     return_value = pysqlite_connection_backup_impl(self, target, pages, progress, name, sleep);
608 
609 exit:
610     return return_value;
611 }
612 
613 PyDoc_STRVAR(pysqlite_connection_create_collation__doc__,
614 "create_collation($self, name, callback, /)\n"
615 "--\n"
616 "\n"
617 "Creates a collation function. Non-standard.");
618 
619 #define PYSQLITE_CONNECTION_CREATE_COLLATION_METHODDEF    \
620     {"create_collation", (PyCFunction)(void(*)(void))pysqlite_connection_create_collation, METH_FASTCALL, pysqlite_connection_create_collation__doc__},
621 
622 static PyObject *
623 pysqlite_connection_create_collation_impl(pysqlite_Connection *self,
624                                           PyObject *name, PyObject *callable);
625 
626 static PyObject *
pysqlite_connection_create_collation(pysqlite_Connection * self,PyObject * const * args,Py_ssize_t nargs)627 pysqlite_connection_create_collation(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
628 {
629     PyObject *return_value = NULL;
630     PyObject *name;
631     PyObject *callable;
632 
633     if (!_PyArg_CheckPositional("create_collation", nargs, 2, 2)) {
634         goto exit;
635     }
636     if (!PyUnicode_Check(args[0])) {
637         _PyArg_BadArgument("create_collation", "argument 1", "str", args[0]);
638         goto exit;
639     }
640     if (PyUnicode_READY(args[0]) == -1) {
641         goto exit;
642     }
643     name = args[0];
644     callable = args[1];
645     return_value = pysqlite_connection_create_collation_impl(self, name, callable);
646 
647 exit:
648     return return_value;
649 }
650 
651 PyDoc_STRVAR(pysqlite_connection_enter__doc__,
652 "__enter__($self, /)\n"
653 "--\n"
654 "\n"
655 "Called when the connection is used as a context manager.\n"
656 "\n"
657 "Returns itself as a convenience to the caller.");
658 
659 #define PYSQLITE_CONNECTION_ENTER_METHODDEF    \
660     {"__enter__", (PyCFunction)pysqlite_connection_enter, METH_NOARGS, pysqlite_connection_enter__doc__},
661 
662 static PyObject *
663 pysqlite_connection_enter_impl(pysqlite_Connection *self);
664 
665 static PyObject *
pysqlite_connection_enter(pysqlite_Connection * self,PyObject * Py_UNUSED (ignored))666 pysqlite_connection_enter(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
667 {
668     return pysqlite_connection_enter_impl(self);
669 }
670 
671 PyDoc_STRVAR(pysqlite_connection_exit__doc__,
672 "__exit__($self, type, value, traceback, /)\n"
673 "--\n"
674 "\n"
675 "Called when the connection is used as a context manager.\n"
676 "\n"
677 "If there was any exception, a rollback takes place; otherwise we commit.");
678 
679 #define PYSQLITE_CONNECTION_EXIT_METHODDEF    \
680     {"__exit__", (PyCFunction)(void(*)(void))pysqlite_connection_exit, METH_FASTCALL, pysqlite_connection_exit__doc__},
681 
682 static PyObject *
683 pysqlite_connection_exit_impl(pysqlite_Connection *self, PyObject *exc_type,
684                               PyObject *exc_value, PyObject *exc_tb);
685 
686 static PyObject *
pysqlite_connection_exit(pysqlite_Connection * self,PyObject * const * args,Py_ssize_t nargs)687 pysqlite_connection_exit(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
688 {
689     PyObject *return_value = NULL;
690     PyObject *exc_type;
691     PyObject *exc_value;
692     PyObject *exc_tb;
693 
694     if (!_PyArg_CheckPositional("__exit__", nargs, 3, 3)) {
695         goto exit;
696     }
697     exc_type = args[0];
698     exc_value = args[1];
699     exc_tb = args[2];
700     return_value = pysqlite_connection_exit_impl(self, exc_type, exc_value, exc_tb);
701 
702 exit:
703     return return_value;
704 }
705 
706 #ifndef PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF
707     #define PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF
708 #endif /* !defined(PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF) */
709 
710 #ifndef PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
711     #define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
712 #endif /* !defined(PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF) */
713 /*[clinic end generated code: output=6c40101de3ae46fc input=a9049054013a1b77]*/
714