Skip to content

Commit cf0b239

Browse files
author
Erlend Egeberg Aasland
authored
bpo-40810: Require SQLite 3.7.15 (GH-24106)
1 parent c7f8d3c commit cf0b239

File tree

9 files changed

+11
-56
lines changed

9 files changed

+11
-56
lines changed

Diff for: Doc/library/sqlite3.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PostgreSQL or Oracle.
1919

2020
The sqlite3 module was written by Gerhard Häring. It provides a SQL interface
2121
compliant with the DB-API 2.0 specification described by :pep:`249`, and
22-
requires SQLite 3.7.3 or newer.
22+
requires SQLite 3.7.15 or newer.
2323

2424
To use the module, you must first create a :class:`Connection` object that
2525
represents the database. Here the data will be stored in the

Diff for: Doc/whatsnew/3.10.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -577,13 +577,12 @@ CPython bytecode changes
577577
Build Changes
578578
=============
579579

580-
581580
* The C99 functions :c:func:`snprintf` and :c:func:`vsnprintf` are now required
582581
to build Python.
583582
(Contributed by Victor Stinner in :issue:`36020`.)
584583

585-
* :mod:`sqlite3` requires SQLite 3.7.3 or higher.
586-
(Contributed by Sergey Fedoseev and Erlend E. Aasland :issue:`40744`.)
584+
* :mod:`sqlite3` requires SQLite 3.7.15 or higher. (Contributed by Sergey Fedoseev
585+
and Erlend E. Aasland :issue:`40744` and :issue:`40810`.)
587586

588587
* The :mod:`atexit` module must now always be built as a built-in module.
589588
(Contributed by Victor Stinner in :issue:`42639`.)

Diff for: Lib/sqlite3/test/dbapi.py

-4
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ def __fspath__(self):
172172
cx.execute('create table test(id integer)')
173173

174174
def CheckOpenUri(self):
175-
if sqlite.sqlite_version_info < (3, 7, 7):
176-
with self.assertRaises(sqlite.NotSupportedError):
177-
sqlite.connect(':memory:', uri=True)
178-
return
179175
self.addCleanup(unlink, TESTFN)
180176
with sqlite.connect(TESTFN) as cx:
181177
cx.execute('create table test(id integer)')

Diff for: Lib/sqlite3/test/hooks.py

-8
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,6 @@ def trace(statement):
260260
cur.execute(queries[0])
261261
con2.execute("create table bar(x)")
262262
cur.execute(queries[1])
263-
264-
# Extract from SQLite 3.7.15 changelog:
265-
# Avoid invoking the sqlite3_trace() callback multiple times when a
266-
# statement is automatically reprepared due to SQLITE_SCHEMA errors.
267-
#
268-
# See bpo-40810
269-
if sqlite.sqlite_version_info < (3, 7, 15):
270-
queries.append(queries[-1])
271263
self.assertEqual(traced_statements, queries)
272264

273265

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Require SQLite 3.7.15 or newer. Patch by Erlend E. Aasland.

Diff for: Modules/_sqlite/connection.c

+2-28
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ void pysqlite_connection_dealloc(pysqlite_Connection* self)
233233

234234
/* Clean up if user has not called .close() explicitly. */
235235
if (self->db) {
236-
SQLITE3_CLOSE(self->db);
236+
sqlite3_close_v2(self->db);
237237
}
238238

239239
Py_XDECREF(self->isolation_level);
@@ -338,7 +338,7 @@ pysqlite_connection_close_impl(pysqlite_Connection *self)
338338
pysqlite_do_all_statements(self, ACTION_FINALIZE, 1);
339339

340340
if (self->db) {
341-
rc = SQLITE3_CLOSE(self->db);
341+
rc = sqlite3_close_v2(self->db);
342342

343343
if (rc != SQLITE_OK) {
344344
_pysqlite_seterror(self->db, NULL);
@@ -1687,33 +1687,7 @@ pysqlite_connection_backup_impl(pysqlite_Connection *self,
16871687
if (rc == SQLITE_NOMEM) {
16881688
(void)PyErr_NoMemory();
16891689
} else {
1690-
#if SQLITE_VERSION_NUMBER > 3007015
16911690
PyErr_SetString(pysqlite_OperationalError, sqlite3_errstr(rc));
1692-
#else
1693-
switch (rc) {
1694-
case SQLITE_ERROR:
1695-
/* Description of SQLITE_ERROR in SQLite 3.7.14 and older
1696-
releases. */
1697-
PyErr_SetString(pysqlite_OperationalError,
1698-
"SQL logic error or missing database");
1699-
break;
1700-
case SQLITE_READONLY:
1701-
PyErr_SetString(pysqlite_OperationalError,
1702-
"attempt to write a readonly database");
1703-
break;
1704-
case SQLITE_BUSY:
1705-
PyErr_SetString(pysqlite_OperationalError, "database is locked");
1706-
break;
1707-
case SQLITE_LOCKED:
1708-
PyErr_SetString(pysqlite_OperationalError,
1709-
"database table is locked");
1710-
break;
1711-
default:
1712-
PyErr_Format(pysqlite_OperationalError,
1713-
"unrecognized error code: %d", rc);
1714-
break;
1715-
}
1716-
#endif
17171691
}
17181692
}
17191693

Diff for: Modules/_sqlite/module.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#include "microprotocols.h"
3030
#include "row.h"
3131

32-
#if SQLITE_VERSION_NUMBER < 3007003
33-
#error "SQLite 3.7.3 or higher required"
32+
#if SQLITE_VERSION_NUMBER < 3007015
33+
#error "SQLite 3.7.15 or higher required"
3434
#endif
3535

3636
#include "clinic/module.c.h"
@@ -365,8 +365,8 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
365365
{
366366
PyObject *module;
367367

368-
if (sqlite3_libversion_number() < 3007003) {
369-
PyErr_SetString(PyExc_ImportError, MODULE_NAME ": SQLite 3.7.3 or higher required");
368+
if (sqlite3_libversion_number() < 3007015) {
369+
PyErr_SetString(PyExc_ImportError, MODULE_NAME ": SQLite 3.7.15 or higher required");
370370
return NULL;
371371
}
372372

Diff for: Modules/_sqlite/util.h

-6
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,4 @@ int _pysqlite_seterror(sqlite3* db, sqlite3_stmt* st);
3939

4040
sqlite_int64 _pysqlite_long_as_int64(PyObject * value);
4141

42-
#if SQLITE_VERSION_NUMBER >= 3007014
43-
#define SQLITE3_CLOSE sqlite3_close_v2
44-
#else
45-
#define SQLITE3_CLOSE sqlite3_close
46-
#endif
47-
4842
#endif

Diff for: setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1444,8 +1444,7 @@ def detect_sqlite(self):
14441444
]
14451445
if CROSS_COMPILING:
14461446
sqlite_inc_paths = []
1447-
# We need to find >= sqlite version 3.7.3, for sqlite3_create_function_v2()
1448-
MIN_SQLITE_VERSION_NUMBER = (3, 7, 3)
1447+
MIN_SQLITE_VERSION_NUMBER = (3, 7, 15) # Issue 40810
14491448
MIN_SQLITE_VERSION = ".".join([str(x)
14501449
for x in MIN_SQLITE_VERSION_NUMBER])
14511450

0 commit comments

Comments
 (0)