Skip to content

Commit

Permalink
[3.10] bpo-45581: Raise MemoryError in sqlite3.connect if SQLite …
Browse files Browse the repository at this point in the history
…signals memory error (GH-29171) (GH-29323)

(cherry picked from commit e2e62b3)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
  • Loading branch information
ambv and Erlend Egeberg Aasland committed Oct 29, 2021
1 parent 0538351 commit 7e2c0a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ pysqlite_connection_init(pysqlite_Connection *self, PyObject *args,

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;
Expand Down

0 comments on commit 7e2c0a1

Please sign in to comment.