]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.9] bpo-45581: Raise `MemoryError` in `sqlite3.connect` if SQLite signals memory...
authorŁukasz Langa <lukasz@langa.pl>
Fri, 29 Oct 2021 21:02:19 +0000 (23:02 +0200)
committerGitHub <noreply@github.com>
Fri, 29 Oct 2021 21:02:19 +0000 (23:02 +0200)
(cherry picked from commit e2e62b3808691e15fa44b883270023e42dcad958)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
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 68bf97389a7cd24aa55429419988a75fb8638281..30e333a4b86d83011ea35452f51e660f145b8d1e 100644 (file)
@@ -134,6 +134,10 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
 
     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;