summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/clinic
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2022-04-16 04:21:12 (GMT)
committerGitHub <noreply@github.com>2022-04-16 04:21:12 (GMT)
commita8617566759a07c67d14c9b6ed663e32d3b3f5e7 (patch)
tree531993ba1515ca7050375c7d840579423dcc4d7f /Modules/_sqlite/clinic
parent4e661cd69164318c1f871faa476c68a04092ddc4 (diff)
downloadcpython-a8617566759a07c67d14c9b6ed663e32d3b3f5e7.zip
cpython-a8617566759a07c67d14c9b6ed663e32d3b3f5e7.tar.gz
cpython-a8617566759a07c67d14c9b6ed663e32d3b3f5e7.tar.bz2
gh-69093: Add context manager support to sqlite3.Blob (GH-91562)
Diffstat (limited to 'Modules/_sqlite/clinic')
-rw-r--r--Modules/_sqlite/clinic/blob.c.h53
1 files changed, 52 insertions, 1 deletions
diff --git a/Modules/_sqlite/clinic/blob.c.h b/Modules/_sqlite/clinic/blob.c.h
index 30b3e3c..237877a 100644
--- a/Modules/_sqlite/clinic/blob.c.h
+++ b/Modules/_sqlite/clinic/blob.c.h
@@ -162,4 +162,55 @@ blob_tell(pysqlite_Blob *self, PyObject *Py_UNUSED(ignored))
{
return blob_tell_impl(self);
}
-/*[clinic end generated code: output=d3a02b127f2cfa58 input=a9049054013a1b77]*/
+
+PyDoc_STRVAR(blob_enter__doc__,
+"__enter__($self, /)\n"
+"--\n"
+"\n"
+"Blob context manager enter.");
+
+#define BLOB_ENTER_METHODDEF \
+ {"__enter__", (PyCFunction)blob_enter, METH_NOARGS, blob_enter__doc__},
+
+static PyObject *
+blob_enter_impl(pysqlite_Blob *self);
+
+static PyObject *
+blob_enter(pysqlite_Blob *self, PyObject *Py_UNUSED(ignored))
+{
+ return blob_enter_impl(self);
+}
+
+PyDoc_STRVAR(blob_exit__doc__,
+"__exit__($self, type, val, tb, /)\n"
+"--\n"
+"\n"
+"Blob context manager exit.");
+
+#define BLOB_EXIT_METHODDEF \
+ {"__exit__", (PyCFunction)(void(*)(void))blob_exit, METH_FASTCALL, blob_exit__doc__},
+
+static PyObject *
+blob_exit_impl(pysqlite_Blob *self, PyObject *type, PyObject *val,
+ PyObject *tb);
+
+static PyObject *
+blob_exit(pysqlite_Blob *self, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ PyObject *type;
+ PyObject *val;
+ PyObject *tb;
+
+ if (!_PyArg_CheckPositional("__exit__", nargs, 3, 3)) {
+ goto exit;
+ }
+ type = args[0];
+ val = args[1];
+ tb = args[2];
+ return_value = blob_exit_impl(self, type, val, tb);
+
+exit:
+ return return_value;
+}
+/*[clinic end generated code: output=ca2400862c18dadb input=a9049054013a1b77]*/