Skip to content

Commit 7e2c0a1

Browse files
ambvErlend Egeberg Aasland
andauthored
[3.10] bpo-45581: Raise MemoryError in sqlite3.connect if SQLite signals memory error (GH-29171) (GH-29323)
(cherry picked from commit e2e62b3) Co-authored-by: Erlend Egeberg Aasland <[email protected]>
1 parent 0538351 commit 7e2c0a1

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
@@ -113,6 +113,10 @@ pysqlite_connection_init(pysqlite_Connection *self, PyObject *args,
113113

114114
Py_DECREF(database_obj);
115115

116+
if (self->db == NULL && rc == SQLITE_NOMEM) {
117+
PyErr_NoMemory();
118+
return -1;
119+
}
116120
if (rc != SQLITE_OK) {
117121
_pysqlite_seterror(self->db, NULL);
118122
return -1;

0 commit comments

Comments
 (0)