8000 bpo-24464: Deprecate sqlite3.enable_shared_cache by erlend-aasland · Pull Request #24008 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-24464: Deprecate sqlite3.enable_shared_cache #24008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-24464: Deprecate sqlite3.enable_shared_cache
  • Loading branch information
Erlend E. Aasland committed Dec 30, 2020
commit 4969fef910e0c553adb6841e0ee896c9e695be75
8 changes: 8 additions & 0 deletions Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,14 @@ Deprecated
scheduled for removal in Python 3.12.
(Contributed by Erlend E. Aasland in :issue:`42264`.)

* ``sqlite3.enable_shared_cache`` is now deprecated, scheduled for removal in
Python 3.12. The method is undocumented, and it's use is strongly
Copy link
Contributor
@ZackerySpytz ZackerySpytz Dec 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Python 3.12. The method is undocumented, and it's use is strongly
Python 3.12. The method is undocumented, and its use is strongly

It is incorrect to use a contraction here.

Also, it seems that sqlite3.enable_shared_cache is not a method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it seems that sqlite3.enable_shared_cache is not a method.

Correct, it's a built-in function. Good catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 7d52671. Is the new phrasing acceptable?

8000

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
=======
Expand Down
14 changes: 14 additions & 0 deletions Lib/sqlite3/dbapi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ def convert_timestamp(val):

register_adapters_and_converters()

# bpo-24464: enable_shared_cache was deprecated in Python 3.10. It's
# scheduled for removal in Python 3.12.
_old_enable_shared_cache = enable_shared_cache
def enable_shared_cache(enable):
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)
7 changes: 7 additions & 0 deletions Lib/sqlite3/test/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ def CheckNotSupportedError(self):
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):
Expand Down
0