| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9b50585 commit 00f22e8
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -107,6 +107,15 @@ Deprecated | |||
| 107 | 107 | Removed | |
| 108 | 108 | ======= | |
| 109 | 109 | ||
| 110 | + * The following undocumented :mod:`sqlite3` features, deprecated in Python | ||
| 111 | + 3.10, are now removed: | ||
| 112 | + | ||
| 113 | + * ``sqlite3.enable_shared_cache()`` | ||
| 114 | + * ``sqlite3.OptimizedUnicode`` | ||
| 115 | + | ||
| 116 | + (Contributed by Erlend E. Aasland in :gh:`92548`) | ||
| 117 | + | ||
| 118 | + | ||
| 110 | 119 | Porting to Python 3.12 | |
| 111 | 120 | ====================== | |
| 112 | 121 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,17 +55,3 @@ | |||
| 55 | 55 | """ | |
| 56 | 56 | ||
| 57 | 57 | from sqlite3.dbapi2 import * | |
| 58 | - | ||
| 59 | - | ||
| 60 | - # bpo-42264: OptimizedUnicode was deprecated in Python 3.10. It's scheduled | ||
| 61 | - # for removal in Python 3.12. | ||
| 62 | - def __getattr__(name): | ||
| 63 | - if name == "OptimizedUnicode": | ||
| 64 | - import warnings | ||
| 65 | - msg = (""" | ||
| 66 | - OptimizedUnicode is deprecated and will be removed in Python 3.12. | ||
| 67 | - Since Python 3.3 it has simply been an alias for 'str'. | ||
| 68 | - """) | ||
| 69 | - warnings.warn(msg, DeprecationWarning, stacklevel=2) | ||
| 70 | - return str | ||
| 71 | - raise AttributeError(f"module 'sqlite3' has no attribute '{name}'") | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,20 +82,6 @@ def convert_timestamp(val): | |||
| 82 | 82 | ||
| 83 | 83 | register_adapters_and_converters() | |
| 84 | 84 | ||
| 85 | - # bpo-24464: enable_shared_cache was deprecated in Python 3.10. It's | ||
| 86 | - # scheduled for removal in Python 3.12. | ||
| 87 | - def enable_shared_cache(enable): | ||
| 88 | - from _sqlite3 import enable_shared_cache as _old_enable_shared_cache | ||
| 89 | - import warnings | ||
| 90 | - msg = ( | ||
| 91 | - "enable_shared_cache is deprecated and will be removed in Python 3.12. " | ||
| 92 | - "Shared cache is strongly discouraged by the SQLite 3 documentation. " | ||
| 93 | - "If shared cache must be used, open the database in URI mode using" | ||
| 94 | - "the cache=shared query parameter." | ||
| 95 | - ) | ||
| 96 | - warnings.warn(msg, DeprecationWarning, stacklevel=2) | ||
| 97 | - return _old_enable_shared_cache(enable) | ||
| 98 | - | ||
| 99 | 85 | # Clean up namespace | |
| 100 | 86 | ||
| 101 | 87 | del(register_adapters_and_converters) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -344,15 +344,6 @@ def test_extended_error_code_on_exception(self): | |||
| 344 | 344 | sqlite.SQLITE_CONSTRAINT_CHECK) | |
| 345 | 345 | self.assertEqual(exc.sqlite_errorname, "SQLITE_CONSTRAINT_CHECK") | |
| 346 | 346 | ||
| 347 | - # sqlite3_enable_shared_cache() is deprecated on macOS and calling it may raise | ||
| 348 | - # OperationalError on some buildbots. | ||
| 349 | - @unittest.skipIf(sys.platform == "darwin", "shared cache is deprecated on macOS") | ||
| 350 | - def test_shared_cache_deprecated(self): | ||
| 351 | - for enable in (True, False): | ||
| 352 | - with self.assertWarns(DeprecationWarning) as cm: | ||
| 353 | - sqlite.enable_shared_cache(enable) | ||
| 354 | - self.assertIn("dbapi.py", cm.filename) | ||
| 355 | - | ||
| 356 | 347 | def test_disallow_instantiation(self): | |
| 357 | 348 | cx = sqlite.connect(":memory:") | |
| 358 | 349 | check_disallow_instantiation(self, type(cx("select 1"))) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -256,18 +256,6 @@ def test_custom(self): | |||
| 256 | 256 | self.assertEqual(type(row[0]), str, "type of row[0] must be unicode") | |
| 257 | 257 | self.assertTrue(row[0].endswith("reich"), "column must contain original data") | |
| 258 | 258 | ||
| 259 | - def test_optimized_unicode(self): | ||
| 260 | - # OptimizedUnicode is deprecated as of Python 3.10 | ||
| 261 | - with self.assertWarns(DeprecationWarning) as cm: | ||
| 262 | - self.con.text_factory = sqlite.OptimizedUnicode | ||
| 263 | - self.assertIn("factory.py", cm.filename) | ||
| 264 | - austria = "Österreich" | ||
| 265 | - germany = "Deutchland" | ||
| 266 | - a_row = self.con.execute("select ?", (austria,)).fetchone() | ||
| 267 | - d_row = self.con.execute("select ?", (germany,)).fetchone() | ||
| 268 | - self.assertEqual(type(a_row[0]), str, "type of non-ASCII row must be str") | ||
| 269 | - self.assertEqual(type(d_row[0]), str, "type of ASCII-only row must be str") | ||
| 270 | - | ||
| 271 | 259 | def tearDown(self): | |
| 272 | 260 | self.con.close() | |
| 273 | 261 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,6 @@ | |||
| 1 | + Remove undocumented :mod:`sqlite3` features deprecated in Python 3.10: | ||
| 2 | + | ||
| 3 | + * ``sqlite3.enable_shared_cache()`` | ||
| 4 | + * ``sqlite3.OptimizedUnicode`` | ||
| 5 | + | ||
| 6 | + Patch by Erlend E. Aasland. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -105,36 +105,6 @@ pysqlite_complete_statement_impl(PyObject *module, const char *statement) | |||
| 105 | 105 | } | |
| 106 | 106 | } | |
| 107 | 107 | ||
| 108 | - /*[clinic input] | ||
| 109 | - _sqlite3.enable_shared_cache as pysqlite_enable_shared_cache | ||
| 110 | - | ||
| 111 | - do_enable: int | ||
| 112 | - | ||
| 113 | - Enable or disable shared cache mode for the calling thread. | ||
| 114 | - | ||
| 115 | - This method is deprecated and will be removed in Python 3.12. | ||
| 116 | - Shared cache is strongly discouraged by the SQLite 3 documentation. | ||
| 117 | - If shared cache must be used, open the database in URI mode using | ||
| 118 | - the cache=shared query parameter. | ||
| 119 | - [clinic start generated code]*/ | ||
| 120 | - | ||
| 121 | - static PyObject * | ||
| 122 | - pysqlite_enable_shared_cache_impl(PyObject *module, int do_enable) | ||
| 123 | - /*[clinic end generated code: output=259c74eedee1516b input=26e40d5971d3487d]*/ | ||
| 124 | - { | ||
| 125 | - int rc; | ||
| 126 | - | ||
| 127 | - rc = sqlite3_enable_shared_cache(do_enable); | ||
| 128 | - | ||
| 129 | - if (rc != SQLITE_OK) { | ||
| 130 | - pysqlite_state *state = pysqlite_get_state(module); | ||
| 131 | - PyErr_SetString(state->OperationalError, "Changing the shared_cache flag failed"); | ||
| 132 | - return NULL; | ||
| 133 | - } else { | ||
| 134 | - Py_RETURN_NONE; | ||
| 135 | - } | ||
| 136 | - } | ||
| 137 | - | ||
| 138 | 108 | /*[clinic input] | |
| 139 | 109 | _sqlite3.register_adapter as pysqlite_register_adapter | |
| 140 | 110 | ||
@@ -277,7 +247,6 @@ static PyMethodDef module_methods[] = { | |||
| 277 | 247 | PYSQLITE_COMPLETE_STATEMENT_METHODDEF | |
| 278 | 248 | PYSQLITE_CONNECT_METHODDEF | |
| 279 | 249 | PYSQLITE_ENABLE_CALLBACK_TRACE_METHODDEF | |
| 280 | - PYSQLITE_ENABLE_SHARED_CACHE_METHODDEF | ||
| 281 | 250 | PYSQLITE_REGISTER_ADAPTER_METHODDEF | |
| 282 | 251 | PYSQLITE_REGISTER_CONVERTER_METHODDEF | |
| 283 | 252 | {NULL, NULL} | |
| Back | FazBrowse Home | New Git URL |
0 commit comments