From 4969fef910e0c553adb6841e0ee896c9e695be75 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Wed, 30 Dec 2020 14:50:32 +0100 Subject: [PATCH 01/10] bpo-24464: Deprecate sqlite3.enable_shared_cache --- Doc/whatsnew/3.10.rst | 8 ++++++++ Lib/sqlite3/dbapi2.py | 14 ++++++++++++++ Lib/sqlite3/test/dbapi.py | 7 +++++++ 3 files changed, 29 insertions(+) diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index b5fb1e9a629c1c..7e9fa126226150 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -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 + discouraged by the SQLite3 documentation. See `the SQLite3 docs + ` 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 991682ce9ef3b7..a82313e45aaae4 100644 --- a/Lib/sqlite3/dbapi2.py +++ b/Lib/sqlite3/dbapi2.py @@ -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) diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py index 7867bf361e5ac6..2219868a45f65a 100644 --- a/Lib/sqlite3/test/dbapi.py +++ b/Lib/sqlite3/test/dbapi.py @@ -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): From 86e95b60e08c328000fc05305de48947ac406921 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Wed, 30 Dec 2020 14:57:18 +0100 Subject: [PATCH 02/10] Add NEWS --- .../next/Library/2020-12-30-14-56-25.bpo-24464.vbNVHe.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2020-12-30-14-56-25.bpo-24464.vbNVHe.rst 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 00000000000000..701441800ab94e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-12-30-14-56-25.bpo-24464.vbNVHe.rst @@ -0,0 +1,3 @@ +``sqlite3.enable_shared_cache`` is now deprecated, scheduled for removal in +Python 3.12. The method is undocumented, and it's use is strongly +discouraged by the SQLite3 documentation. Patch by Erlend E. Aasland From 13a1eb17656dfce03c735bb7b1ece723f38f8313 Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Thu, 31 Dec 2020 20:05:32 +0100 Subject: [PATCH 03/10] Fix typo: it's => its Co-authored-by: Zackery Spytz --- .../next/Library/2020-12-30-14-56-25.bpo-24464.vbNVHe.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 701441800ab94e..b03af495a5d244 100644 --- 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 @@ -1,3 +1,3 @@ ``sqlite3.enable_shared_cache`` is now deprecated, scheduled for removal in -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 discouraged by the SQLite3 documentation. Patch by Erlend E. Aasland From f93c455a1611432e099d649b80473223e3ca4532 Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Thu, 31 Dec 2020 20:06:13 +0100 Subject: [PATCH 04/10] Add missing punctuation mark. Co-authored-by: Zackery Spytz --- .../next/Library/2020-12-30-14-56-25.bpo-24464.vbNVHe.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index b03af495a5d244..4f927f2d274144 100644 --- 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 @@ -1,3 +1,3 @@ ``sqlite3.enable_shared_cache`` is now deprecated, scheduled for removal in Python 3.12. The method is undocumented, and its use is strongly -discouraged by the SQLite3 documentation. Patch by Erlend E. Aasland +discouraged by the SQLite3 documentation. Patch by Erlend E. Aasland. From 5fa59187963e5df52b394739a9c10e935bccd713 Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Thu, 31 Dec 2020 20:06:35 +0100 Subject: [PATCH 05/10] Fix typo: it's => its Co-authored-by: Zackery Spytz --- Doc/whatsnew/3.10.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 7e9fa126226150..867c2c71a1f6af 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -463,7 +463,7 @@ Deprecated (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 + Python 3.12. The method is undocumented, and its use is strongly discouraged by the SQLite3 documentation. See `the SQLite3 docs ` for more details. If shared cache must be used, open the database in URI mode using the From 7d526714107051cf248245676383d5ac6b7aaf82 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 31 Dec 2020 20:13:20 +0100 Subject: [PATCH 06/10] Address review: it's not a method, it's a built-in function --- Doc/whatsnew/3.10.rst | 4 ++-- .../next/Library/2020-12-30-14-56-25.bpo-24464.vbNVHe.rst | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 867c2c71a1f6af..0ca35d10eb483e 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -462,8 +462,8 @@ 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 its use is strongly +* 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 ` for more details. If shared cache must be used, open the database in URI mode using the 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 index 4f927f2d274144..2039c1ca9c0c46 100644 --- 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 @@ -1,3 +1,3 @@ -``sqlite3.enable_shared_cache`` is now deprecated, scheduled for removal in -Python 3.12. The method is undocumented, and its use is strongly -discouraged by the SQLite3 documentation. Patch by Erlend E. Aasland. +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. From 03e36d0505453a349a84c7ecdd3a3261c95de67f Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 4 Jan 2021 23:34:43 +0100 Subject: [PATCH 07/10] Address review: Make override reload safe --- Lib/sqlite3/dbapi2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/sqlite3/dbapi2.py b/Lib/sqlite3/dbapi2.py index a82313e45aaae4..700f5ccb64d7c3 100644 --- a/Lib/sqlite3/dbapi2.py +++ b/Lib/sqlite3/dbapi2.py @@ -86,7 +86,7 @@ def convert_timestamp(val): # 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 +from _sqlite3 import enable_shared_cache as _old_enable_shared_cache def enable_shared_cache(enable): import warnings msg = (""" From cd11c78270bfc9ef0ef8a75645c383e4000994db Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 4 Jan 2021 23:38:14 +0100 Subject: [PATCH 08/10] Address review: Improve formatting --- Lib/sqlite3/dbapi2.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/sqlite3/dbapi2.py b/Lib/sqlite3/dbapi2.py index 700f5ccb64d7c3..02fc64e7ed1dc4 100644 --- a/Lib/sqlite3/dbapi2.py +++ b/Lib/sqlite3/dbapi2.py @@ -89,12 +89,12 @@ def convert_timestamp(val): from _sqlite3 import enable_shared_cache as _old_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. - """) + 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 From 97b04526082d110631db5038c480a30d399ec56b Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Tue, 5 Jan 2021 00:09:27 +0100 Subject: [PATCH 09/10] Improve scope --- Lib/sqlite3/dbapi2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/sqlite3/dbapi2.py b/Lib/sqlite3/dbapi2.py index 02fc64e7ed1dc4..6475f98a646f9e 100644 --- a/Lib/sqlite3/dbapi2.py +++ b/Lib/sqlite3/dbapi2.py @@ -86,8 +86,8 @@ def convert_timestamp(val): # bpo-24464: enable_shared_cache was deprecated in Python 3.10. It's # scheduled for removal in Python 3.12. -from _sqlite3 import enable_shared_cache as _old_enable_shared_cache 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. " From cf5dca461704597e5bf3674405895f79c0f25017 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Wed, 6 Jan 2021 02:10:47 +0200 Subject: [PATCH 10/10] fix url markup --- Doc/whatsnew/3.10.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 0ca35d10eb483e..5be1f0b9c020ec 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -465,8 +465,8 @@ Deprecated * 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 - ` for more details. If - shared cache must be used, open the database in URI mode using the + `_ 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`.) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy