From: Ɓukasz Langa Date: Fri, 29 Oct 2021 20:54:07 +0000 (+0200) Subject: [3.10] bpo-45581: Raise `MemoryError` in `sqlite3.connect` if SQLite signals memory... X-Git-Tag: v3.10.1~117 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7e2c0a18b41cb906a354776e6ca52af81e39820f;p=thirdparty%2FPython%2Fcpython.git [3.10] bpo-45581: Raise `MemoryError` in `sqlite3.connect` if SQLite signals memory error (GH-29171) (GH-29323) (cherry picked from commit e2e62b3808691e15fa44b883270023e42dcad958) Co-authored-by: Erlend Egeberg Aasland --- diff --git a/Misc/NEWS.d/next/Library/2021-10-22-21-57-02.bpo-45581.rlH6ay.rst b/Misc/NEWS.d/next/Library/2021-10-22-21-57-02.bpo-45581.rlH6ay.rst new file mode 100644 index 000000000000..13a3b237434e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-10-22-21-57-02.bpo-45581.rlH6ay.rst @@ -0,0 +1,2 @@ +:meth:`sqlite3.connect` now correctly raises :exc:`MemoryError` if the +underlying SQLite API signals memory error. Patch by Erlend E. Aasland. diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 2cc5f53a30bc..64610393ec1c 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -113,6 +113,10 @@ pysqlite_connection_init(pysqlite_Connection *self, PyObject *args, Py_DECREF(database_obj); + if (self->db == NULL && rc == SQLITE_NOMEM) { + PyErr_NoMemory(); + return -1; + } if (rc != SQLITE_OK) { _pysqlite_seterror(self->db, NULL); return -1;