mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-24464: Deprecate sqlite3.enable_shared_cache (GH-24008)
This commit is contained in:
parent
f9949f82e1
commit
ddb5e11683
4 changed files with 32 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue