Skip to content

Commit e2e62b3

Browse files
author
Erlend Egeberg Aasland
authored
bpo-45581: Raise MemoryError in sqlite3.connect if SQLite signals memory error (pythonGH-29171)
1 parent b17cfd1 commit e2e62b3

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
@@ -165,6 +165,10 @@ pysqlite_connection_init_impl(pysqlite_Connection *self,
165165
(uri ? SQLITE_OPEN_URI : 0), NULL);
166166
Py_END_ALLOW_THREADS
167167

168+
if (self->db == NULL && rc == SQLITE_NOMEM) {
169+
PyErr_NoMemory();
170+
return -1;
171+
}
168172
if (rc != SQLITE_OK) {
169173
_pysqlite_seterror(state, self->db);
170174
return -1;

0 commit comments

Comments
 (0)