Skip to content

Commit 24ed220

Browse files
committed
Don't support blob operation
1 parent 7ea9719 commit 24ed220

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Lib/sqlite3/test/dbapi.py

+4
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,10 @@ def CheckBlobRepeateNotSupported(self):
677677
with self.assertRaises(SystemError):
678678
self.blob * 5
679679

680+
def CheckBlobContainsNotSupported(self):
681+
with self.assertRaises(SystemError):
682+
b"aaaaa" in self.blob
683+
680684
@unittest.skipUnless(threading, 'This test requires threading.')
681685
class ThreadTests(unittest.TestCase):
682686
def setUp(self):

Modules/_sqlite/blob.c

+10
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,15 @@ static PyObject* pysqlite_blob_repeat(pysqlite_Blob *self, PyObject *args)
327327
return NULL;
328328
}
329329

330+
static int pysqlite_blob_contains(pysqlite_Blob *self, PyObject *args)
331+
{
332+
if (pysqlite_check_blob(self)) {
333+
PyErr_SetString(PyExc_SystemError,
334+
"Blob don't support cotains operation");
335+
}
336+
return -1;
337+
}
338+
330339
static PyObject* pysqlite_blob_item(pysqlite_Blob *self, Py_ssize_t i)
331340
{
332341
if (!pysqlite_check_blob(self)) {
@@ -606,6 +615,7 @@ static PySequenceMethods blob_sequence_methods = {
606615
.sq_repeat = (ssizeargfunc)pysqlite_blob_repeat,
607616
.sq_item = (ssizeargfunc)pysqlite_blob_item,
608617
.sq_ass_item = (ssizeobjargproc)pysqlite_blob_ass_item,
618+
.sq_contains = (objobjproc)pysqlite_blob_contains,
609619
};
610620

611621
static PyMappingMethods blob_mapping_methods = {

0 commit comments

Comments
 (0)