Skip to content

Commit ed807bf

Browse files
ambvErlend Egeberg Aasland
and
Erlend Egeberg Aasland
authored
[3.9] bpo-45581: Raise MemoryError in sqlite3.connect if SQLite signals memory error (GH-29171) (GH-29324)
(cherry picked from commit e2e62b3) Co-authored-by: Erlend Egeberg Aasland <[email protected]>
1 parent 3ec1124 commit ed807bf

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:meth:`sqlite3.connect` now correctly raises :exc:`MemoryError` if the
2+
underlying SQLite API signals memory error. Patch by Erlend E. Aasland.

Modules/_sqlite/connection.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
134134

135135
Py_DECREF(database_obj);
136136

137+
if (self->db == NULL && rc == SQLITE_NOMEM) {
138+
PyErr_NoMemory();
139+
return -1;
140+
}
137141
if (rc != SQLITE_OK) {
138142
_pysqlite_seterror(self->db, NULL);
139143
return -1;

0 commit comments

Comments
 (0)