]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45581: Raise `MemoryError` in `sqlite3.connect` if SQLite signals memory error...
authorErlend Egeberg Aasland <erlend.aasland@innova.no>
Fri, 29 Oct 2021 20:21:58 +0000 (22:21 +0200)
committerGitHub <noreply@github.com>
Fri, 29 Oct 2021 20:21:58 +0000 (22:21 +0200)
Misc/NEWS.d/next/Library/2021-10-22-21-57-02.bpo-45581.rlH6ay.rst [new file with mode: 0644]
Modules/_sqlite/connection.c

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 (file)
index 0000000..13a3b23
--- /dev/null
@@ -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.
index da2f12e8f99c2a04fec9994c599acd5fdea024cf..94c38ad3954405b1fc466b0b44f5816e3cdc65d7 100644 (file)
@@ -165,6 +165,10 @@ pysqlite_connection_init_impl(pysqlite_Connection *self,
                          (uri ? SQLITE_OPEN_URI : 0), NULL);
     Py_END_ALLOW_THREADS
 
+    if (self->db == NULL && rc == SQLITE_NOMEM) {
+        PyErr_NoMemory();
+        return -1;
+    }
     if (rc != SQLITE_OK) {
         _pysqlite_seterror(state, self->db);
         return -1;