summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-01-06 00:36:04 (GMT)
committerGitHub <noreply@github.com>2021-01-06 00:36:04 (GMT)
commitddb5e11683c8db9d2095f2f9406701443c4dc9b3 (patch)
tree1f6aade790390220158f852c9e78d9e58faa27d8
parentf9949f82e17c88609adb53eff3a7d5cd63a645bd (diff)
downloadcpython-ddb5e11683c8db9d2095f2f9406701443c4dc9b3.zip
cpython-ddb5e11683c8db9d2095f2f9406701443c4dc9b3.tar.gz
cpython-ddb5e11683c8db9d2095f2f9406701443c4dc9b3.tar.bz2
bpo-24464: Deprecate sqlite3.enable_shared_cache (GH-24008)
-rw-r--r--Doc/whatsnew/3.10.rst8
-rw-r--r--Lib/sqlite3/dbapi2.py14
-rw-r--r--Lib/sqlite3/test/dbapi.py7
-rw-r--r--Misc/NEWS.d/next/Library/2020-12-30-14-56-25.bpo-24464.vbNVHe.rst3
4 files changed, 32 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index 444f132..e615574 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -486,6 +486,14 @@ Deprecated
scheduled for removal in Python 3.12.
(Contributed by Erlend E. Aasland in :issue:`42264`.)
+* The undocumented built-in function ``sqlite3.enable_shared_cache`` is now
+ deprecated, scheduled for removal in Python 3.12. Its use is strongly
+ discouraged by the SQLite3 documentation. See `the SQLite3 docs
+ <https://sqlite.org/c3ref/enable_shared_cache.html/>`_ for more details.
+ If shared cache must be used, open the database in URI mode using the
+ ``cache=shared`` query parameter.
+ (Contributed by Erlend E. Aasland in :issue:`24464`.)
+
Removed
=======
diff --git a/Lib/sqlite3/dbapi2.py b/Lib/sqlite3/dbapi2.py
index 991682c..6475f98 100644
--- a/Lib/sqlite3/dbapi2.py
+++ b/Lib/sqlite3/dbapi2.py
@@ -84,6 +84,20 @@ def register_adapters_and_converters():
register_adapters_and_converters()
+# bpo-24464: enable_shared_cache was deprecated in Python 3.10. It's
+# scheduled for removal in Python 3.12.
+def enable_shared_cache(enable):
+ from _sqlite3 import enable_shared_cache as _old_enable_shared_cache
+ import warnings
+ msg = (
+ "enable_shared_cache is deprecated and will be removed in Python 3.12. "
+ "Shared cache is strongly discouraged by the SQLite 3 documentation. "
+ "If shared cache must be used, open the database in URI mode using"
+ "the cache=shared query parameter."
+ )
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
+ return _old_enable_shared_cache
+
# Clean up namespace
del(register_adapters_and_converters)
diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py
index 2b85ef9..3131c1e 100644
--- a/Lib/sqlite3/test/dbapi.py
+++ b/Lib/sqlite3/test/dbapi.py
@@ -83,6 +83,13 @@ class ModuleTests(unittest.TestCase):
sqlite.DatabaseError),
"NotSupportedError is not a subclass of DatabaseError")
+ def CheckSharedCacheDeprecated(self):
+ for enable in (True, False):
+ with self.assertWarns(DeprecationWarning) as cm:
+ sqlite.enable_shared_cache(enable)
+ self.assertIn("dbapi.py", cm.filename)
+
+
class ConnectionTests(unittest.TestCase):
def setUp(self):
diff --git a/Misc/NEWS.d/next/Library/2020-12-30-14-56-25.bpo-24464.vbNVHe.rst b/Misc/NEWS.d/next/Library/2020-12-30-14-56-25.bpo-24464.vbNVHe.rst
new file mode 100644
index 0000000..2039c1c
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-12-30-14-56-25.bpo-24464.vbNVHe.rst
@@ -0,0 +1,3 @@
+The undocumented built-in function ``sqlite3.enable_shared_cache`` is now
+deprecated, scheduled for removal in Python 3.12. Its use is strongly
+discouraged by the SQLite3 documentation. Patch by Erlend E. Aasland.