From 2a586c43a5837797d9232584aec8e736a2bfcf89 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Sat, 25 Jun 2022 23:47:15 +0200 Subject: [PATCH 1/8] gh-90016: Deprecate default sqlite3 adapters and converters --- Doc/includes/sqlite3/pysqlite_datetime.py | 22 ----------- Doc/library/sqlite3.rst | 39 +++++++++++-------- Doc/whatsnew/3.12.rst | 3 ++ Lib/sqlite3/dbapi2.py | 8 ++++ Lib/test/test_sqlite3/test_regression.py | 6 ++- Lib/test/test_sqlite3/test_types.py | 31 ++++++++++----- ...2-06-25-23-44-44.gh-issue-90016.EB409s.rst | 2 + 7 files changed, 61 insertions(+), 50 deletions(-) delete mode 100644 Doc/includes/sqlite3/pysqlite_datetime.py create mode 100644 Misc/NEWS.d/next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst diff --git a/Doc/includes/sqlite3/pysqlite_datetime.py b/Doc/includes/sqlite3/pysqlite_datetime.py deleted file mode 100644 index 5d843f906b3062..00000000000000 --- a/Doc/includes/sqlite3/pysqlite_datetime.py +++ /dev/null @@ -1,22 +0,0 @@ -import sqlite3 -import datetime - -con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) -cur = con.cursor() -cur.execute("create table test(d date, ts timestamp)") - -today = datetime.date.today() -now = datetime.datetime.now() - -cur.execute("insert into test(d, ts) values (?, ?)", (today, now)) -cur.execute("select d, ts from test") -row = cur.fetchone() -print(today, "=>", row[0], type(row[0])) -print(now, "=>", row[1], type(row[1])) - -cur.execute('select current_date as "d [date]", current_timestamp as "ts [timestamp]"') -row = cur.fetchone() -print("current_date", row[0], type(row[0])) -print("current_timestamp", row[1], type(row[1])) - -con.close() diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index a99485b6ba7bc4..beaa697c94a9e1 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -1305,6 +1305,8 @@ This function can then be registered using :func:`register_adapter`. .. literalinclude:: ../includes/sqlite3/adapter_point_2.py +.. _sqlite3-converters: + Converting SQLite values to custom Python types ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1345,27 +1347,24 @@ The following example illustrates the implicit and explicit approaches: .. literalinclude:: ../includes/sqlite3/converter_point.py -Default adapters and converters -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -There are default adapters for the date and datetime types in the datetime -module. They will be sent as ISO dates/ISO timestamps to SQLite. +Default adapters and converters (deprecated) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The default converters are registered under the name "date" for -:class:`datetime.date` and under the name "timestamp" for -:class:`datetime.datetime`. - -This way, you can use date/timestamps from Python without any additional -fiddling in most cases. The format of the adapters is also compatible with the -experimental SQLite date/time functions. +.. note:: -The following example demonstrates this. + The default adapters and converters are deprecated as of Python 3.12. + Use the :ref:`sqlite3-adapter-converter-recipes` + and tailor them to you need. -.. literalinclude:: ../includes/sqlite3/pysqlite_datetime.py +The deprecated default adapters and converters consists of: -If a timestamp stored in SQLite has a fractional part longer than 6 -numbers, its value will be truncated to microsecond precision by the -timestamp converter. +* Adapt :class:`datetime.date` objects to ISO format :class:`strings `. +* Adapt :class:`datetime.datetime` objects to ISO format :class:`strings `. +* Convert :ref:`declared ` "date" types to ``datetime.date`` + objects. +* Convert declared "timestamp" types to ``datetime.datetime`` objects. + If a timestamp stored in SQLite has a fractional part longer than 6 + numbers, its value will be truncated to microsecond precision. .. note:: @@ -1374,6 +1373,12 @@ timestamp converter. offsets in timestamps, either leave converters disabled, or register an offset-aware converter with :func:`register_converter`. +.. versionchanged:: 3.12 + + Deprecated default adapters and converters. + +.. deprecated:: 3.12 + .. _sqlite3-adapter-converter-recipes: diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index f8de5f503e7312..35910d534a463e 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -118,6 +118,9 @@ CPython bytecode changes Deprecated ========== +* The default :mod:`sqlite3` adapters and converters are now deprecated. + (Contributed by Erlend E. Aasland in :gh:`90016`.) + Pending Removal in Python 3.13 ============================== diff --git a/Lib/sqlite3/dbapi2.py b/Lib/sqlite3/dbapi2.py index 3b6d2f7ba2d595..690d43165ca0e0 100644 --- a/Lib/sqlite3/dbapi2.py +++ b/Lib/sqlite3/dbapi2.py @@ -55,16 +55,24 @@ def TimestampFromTicks(ticks): collections.abc.Sequence.register(Row) def register_adapters_and_converters(): + from warnings import warn + + msg = "The default {what} are deprecated as of Python 3.12" + def adapt_date(val): + warn(msg.format(what="adapters"), DeprecationWarning, stacklevel=2) return val.isoformat() def adapt_datetime(val): + warn(msg.format(what="adapters"), DeprecationWarning, stacklevel=2) return val.isoformat(" ") def convert_date(val): + warn(msg.format(what="converters"), DeprecationWarning, stacklevel=2) return datetime.date(*map(int, val.split(b"-"))) def convert_timestamp(val): + warn(msg.format(what="converters"), DeprecationWarning, stacklevel=2) datepart, timepart = val.split(b" ") year, month, day = map(int, datepart.split(b"-")) timepart_full = timepart.split(b".") diff --git a/Lib/test/test_sqlite3/test_regression.py b/Lib/test/test_sqlite3/test_regression.py index 0b727cecb0e8cb..60501592484087 100644 --- a/Lib/test/test_sqlite3/test_regression.py +++ b/Lib/test/test_sqlite3/test_regression.py @@ -129,7 +129,8 @@ def test_type_map_usage(self): con = sqlite.connect(":memory:",detect_types=sqlite.PARSE_DECLTYPES) cur = con.cursor() cur.execute("create table foo(bar timestamp)") - cur.execute("insert into foo(bar) values (?)", (datetime.datetime.now(),)) + with self.assertWarnsRegex(DeprecationWarning, "adapters"): + cur.execute("insert into foo(bar) values (?)", (datetime.datetime.now(),)) cur.execute(SELECT) cur.execute("drop table foo") cur.execute("create table foo(bar integer)") @@ -305,7 +306,8 @@ def test_convert_timestamp_microsecond_padding(self): cur.execute("INSERT INTO t (x) VALUES ('2012-04-04 15:06:00.123456789')") cur.execute("SELECT * FROM t") - values = [x[0] for x in cur.fetchall()] + with self.assertWarnsRegex(DeprecationWarning, "converters"): + values = [x[0] for x in cur.fetchall()] self.assertEqual(values, [ datetime.datetime(2012, 4, 4, 15, 6, 0, 456000), diff --git a/Lib/test/test_sqlite3/test_types.py b/Lib/test/test_sqlite3/test_types.py index 177cd102350397..51c2e2432cde3a 100644 --- a/Lib/test/test_sqlite3/test_types.py +++ b/Lib/test/test_sqlite3/test_types.py @@ -496,38 +496,51 @@ def tearDown(self): def test_sqlite_date(self): d = sqlite.Date(2004, 2, 14) - self.cur.execute("insert into test(d) values (?)", (d,)) + with self.assertWarnsRegex(DeprecationWarning, "adapters") as cm: + self.cur.execute("insert into test(d) values (?)", (d,)) + self.assertEqual(cm.filename, __file__) self.cur.execute("select d from test") - d2 = self.cur.fetchone()[0] + with self.assertWarnsRegex(DeprecationWarning, "converters") as cm: + d2 = self.cur.fetchone()[0] + self.assertEqual(cm.filename, __file__) self.assertEqual(d, d2) def test_sqlite_timestamp(self): ts = sqlite.Timestamp(2004, 2, 14, 7, 15, 0) - self.cur.execute("insert into test(ts) values (?)", (ts,)) + with self.assertWarnsRegex(DeprecationWarning, "adapters") as cm: + self.cur.execute("insert into test(ts) values (?)", (ts,)) + self.assertEqual(cm.filename, __file__) self.cur.execute("select ts from test") - ts2 = self.cur.fetchone()[0] + with self.assertWarnsRegex(DeprecationWarning, "converters") as cm: + ts2 = self.cur.fetchone()[0] + self.assertEqual(cm.filename, __file__) self.assertEqual(ts, ts2) def test_sql_timestamp(self): now = datetime.datetime.utcnow() self.cur.execute("insert into test(ts) values (current_timestamp)") self.cur.execute("select ts from test") - ts = self.cur.fetchone()[0] + with self.assertWarnsRegex(DeprecationWarning, "converters"): + ts = self.cur.fetchone()[0] self.assertEqual(type(ts), datetime.datetime) self.assertEqual(ts.year, now.year) def test_date_time_sub_seconds(self): ts = sqlite.Timestamp(2004, 2, 14, 7, 15, 0, 500000) - self.cur.execute("insert into test(ts) values (?)", (ts,)) + with self.assertWarnsRegex(DeprecationWarning, "adapters"): + self.cur.execute("insert into test(ts) values (?)", (ts,)) self.cur.execute("select ts from test") - ts2 = self.cur.fetchone()[0] + with self.assertWarnsRegex(DeprecationWarning, "converters"): + ts2 = self.cur.fetchone()[0] self.assertEqual(ts, ts2) def test_date_time_sub_seconds_floating_point(self): ts = sqlite.Timestamp(2004, 2, 14, 7, 15, 0, 510241) - self.cur.execute("insert into test(ts) values (?)", (ts,)) + with self.assertWarnsRegex(DeprecationWarning, "adapters"): + self.cur.execute("insert into test(ts) values (?)", (ts,)) self.cur.execute("select ts from test") - ts2 = self.cur.fetchone()[0] + with self.assertWarnsRegex(DeprecationWarning, "converters"): + ts2 = self.cur.fetchone()[0] self.assertEqual(ts, ts2) diff --git a/Misc/NEWS.d/next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst b/Misc/NEWS.d/next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst new file mode 100644 index 00000000000000..ce9db1791d9ea6 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst @@ -0,0 +1,2 @@ +Deprecate default :mod:`sqlite3` adapters and converters. Patch by Erlend E. +Aasland. From 2ba83f60ad511236fe666916bf9d541f3cd988c7 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Sun, 26 Jun 2022 21:58:50 +0200 Subject: [PATCH 2/8] Address first part of Ian's review --- Doc/library/sqlite3.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index beaa697c94a9e1..13fc1ed9b0fc43 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -1358,13 +1358,12 @@ Default adapters and converters (deprecated) The deprecated default adapters and converters consists of: -* Adapt :class:`datetime.date` objects to ISO format :class:`strings `. -* Adapt :class:`datetime.datetime` objects to ISO format :class:`strings `. +* Adapt :class:`datetime.date` objects to :class:`strings ` in ISO format. +* Adapt :class:`datetime.datetime` objects to strings ISO format. * Convert :ref:`declared ` "date" types to ``datetime.date`` objects. * Convert declared "timestamp" types to ``datetime.datetime`` objects. - If a timestamp stored in SQLite has a fractional part longer than 6 - numbers, its value will be truncated to microsecond precision. + Fractional parts will be truncated to 6 digits (microsecond precision). .. note:: From fb18ab653e50b4f1a6649a9a39e4d6b176e404e8 Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Mon, 27 Jun 2022 18:00:34 +0200 Subject: [PATCH 3/8] Update Doc/library/sqlite3.rst --- Doc/library/sqlite3.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 13fc1ed9b0fc43..59f0a3f39d4f2d 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -1353,7 +1353,7 @@ Default adapters and converters (deprecated) .. note:: The default adapters and converters are deprecated as of Python 3.12. - Use the :ref:`sqlite3-adapter-converter-recipes` + Instead, use the :ref:`sqlite3-adapter-converter-recipes` and tailor them to you need. The deprecated default adapters and converters consists of: From 27eaa235023f7f0d2c5260116ed51c470665cda8 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 27 Jun 2022 18:02:37 +0200 Subject: [PATCH 4/8] Wordings --- Doc/library/sqlite3.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 59f0a3f39d4f2d..26a67c3b46000a 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -1353,8 +1353,8 @@ Default adapters and converters (deprecated) .. note:: The default adapters and converters are deprecated as of Python 3.12. - Instead, use the :ref:`sqlite3-adapter-converter-recipes` - and tailor them to you need. + Instead, use the :ref:`sqlite3-adapter-converter-recipes`, + and tailor them to your needs. The deprecated default adapters and converters consists of: From d3dd3b4ea45690c602a0ce0a156df04ccabd139b Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Sat, 2 Jul 2022 00:16:55 +0200 Subject: [PATCH 5/8] Address review --- Doc/library/sqlite3.rst | 25 +++++++++++-------- Doc/whatsnew/3.12.rst | 5 +++- Lib/sqlite3/dbapi2.py | 3 ++- ...2-06-25-23-44-44.gh-issue-90016.EB409s.rst | 4 +-- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 26a67c3b46000a..12f1a435368447 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -1347,22 +1347,27 @@ The following example illustrates the implicit and explicit approaches: .. literalinclude:: ../includes/sqlite3/converter_point.py +.. _sqlite3-default-converters: + Default adapters and converters (deprecated) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. note:: The default adapters and converters are deprecated as of Python 3.12. - Instead, use the :ref:`sqlite3-adapter-converter-recipes`, + Instead, use the :ref:`sqlite3-adapter-converter-recipes` and tailor them to your needs. -The deprecated default adapters and converters consists of: +The deprecated default adapters and converters consist of: -* Adapt :class:`datetime.date` objects to :class:`strings ` in ISO format. -* Adapt :class:`datetime.datetime` objects to strings ISO format. -* Convert :ref:`declared ` "date" types to ``datetime.date`` - objects. -* Convert declared "timestamp" types to ``datetime.datetime`` objects. +* An adapter for :class:`datetime.date` objects to :class:`strings ` in + `ISO 8601`_ format. +* An adapter for :class:`datetime.datetime` objects to strings in + ISO 8601 format. +* A converter for :ref:`declared ` "date" types to + :class:`datetime.date` objects. +* A converter for declared "timestamp" types to + :class:`datetime.datetime` objects. Fractional parts will be truncated to 6 digits (microsecond precision). .. note:: @@ -1372,12 +1377,10 @@ The deprecated default adapters and converters consists of: offsets in timestamps, either leave converters disabled, or register an offset-aware converter with :func:`register_converter`. -.. versionchanged:: 3.12 - - Deprecated default adapters and converters. - .. deprecated:: 3.12 +.. _ISO 8601: https://en.wikipedia.org/wiki/ISO_8601 + .. _sqlite3-adapter-converter-recipes: diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 35910d534a463e..a2a15c60d448c2 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -118,7 +118,10 @@ CPython bytecode changes Deprecated ========== -* The default :mod:`sqlite3` adapters and converters are now deprecated. +* The :mod:`sqlite3` :ref:`default adapters and converters + ` are now deprecated. + Instead, use the :ref:`sqlite3-adapter-converter-recipes`, + and tailor them to your needs. (Contributed by Erlend E. Aasland in :gh:`90016`.) diff --git a/Lib/sqlite3/dbapi2.py b/Lib/sqlite3/dbapi2.py index 690d43165ca0e0..0aed8fa45ba6c9 100644 --- a/Lib/sqlite3/dbapi2.py +++ b/Lib/sqlite3/dbapi2.py @@ -57,7 +57,8 @@ def TimestampFromTicks(ticks): def register_adapters_and_converters(): from warnings import warn - msg = "The default {what} are deprecated as of Python 3.12" + msg = ("The default {what} are deprecated as of Python 3.12; " + "see the sqlite3 documentation for suggested replacement recipes") def adapt_date(val): warn(msg.format(what="adapters"), DeprecationWarning, stacklevel=2) diff --git a/Misc/NEWS.d/next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst b/Misc/NEWS.d/next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst index ce9db1791d9ea6..7eca4123d2ba6f 100644 --- a/Misc/NEWS.d/next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst +++ b/Misc/NEWS.d/next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst @@ -1,2 +1,2 @@ -Deprecate default :mod:`sqlite3` adapters and converters. Patch by Erlend E. -Aasland. +Deprecate default :mod:`sqlite3` :ref:`default adapters and converters +`. Patch by Erlend E. Aasland. From df4dc318e04143243f593a70266d10037b68e4df Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Sat, 2 Jul 2022 08:34:37 +0200 Subject: [PATCH 6/8] Update Misc/NEWS.d/next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst Co-authored-by: CAM Gerlach --- .../next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst b/Misc/NEWS.d/next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst index 7eca4123d2ba6f..040ba44be2b912 100644 --- a/Misc/NEWS.d/next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst +++ b/Misc/NEWS.d/next/Library/2022-06-25-23-44-44.gh-issue-90016.EB409s.rst @@ -1,2 +1,2 @@ -Deprecate default :mod:`sqlite3` :ref:`default adapters and converters +Deprecate :mod:`sqlite3` :ref:`default adapters and converters `. Patch by Erlend E. Aasland. From ffdf631d0f70f7b24f0120652a64ccd861b47447 Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Sat, 2 Jul 2022 08:34:47 +0200 Subject: [PATCH 7/8] Update Doc/whatsnew/3.12.rst Co-authored-by: CAM Gerlach --- Doc/whatsnew/3.12.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index a2a15c60d448c2..9f7a5b01f4fff0 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -120,7 +120,7 @@ Deprecated * The :mod:`sqlite3` :ref:`default adapters and converters ` are now deprecated. - Instead, use the :ref:`sqlite3-adapter-converter-recipes`, + Instead, use the :ref:`sqlite3-adapter-converter-recipes` and tailor them to your needs. (Contributed by Erlend E. Aasland in :gh:`90016`.) From 6213c3bb2628ed5b9826cd6104e81b595f3b65ea Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Tue, 5 Jul 2022 00:29:59 +0200 Subject: [PATCH 8/8] Address Mariusz' review --- Lib/sqlite3/dbapi2.py | 10 +++++----- Lib/test/test_sqlite3/test_regression.py | 4 ++-- Lib/test/test_sqlite3/test_types.py | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Lib/sqlite3/dbapi2.py b/Lib/sqlite3/dbapi2.py index 0aed8fa45ba6c9..56fc0461e6c922 100644 --- a/Lib/sqlite3/dbapi2.py +++ b/Lib/sqlite3/dbapi2.py @@ -57,23 +57,23 @@ def TimestampFromTicks(ticks): def register_adapters_and_converters(): from warnings import warn - msg = ("The default {what} are deprecated as of Python 3.12; " + msg = ("The default {what} is deprecated as of Python 3.12; " "see the sqlite3 documentation for suggested replacement recipes") def adapt_date(val): - warn(msg.format(what="adapters"), DeprecationWarning, stacklevel=2) + warn(msg.format(what="date adapter"), DeprecationWarning, stacklevel=2) return val.isoformat() def adapt_datetime(val): - warn(msg.format(what="adapters"), DeprecationWarning, stacklevel=2) + warn(msg.format(what="datetime adapter"), DeprecationWarning, stacklevel=2) return val.isoformat(" ") def convert_date(val): - warn(msg.format(what="converters"), DeprecationWarning, stacklevel=2) + warn(msg.format(what="date converter"), DeprecationWarning, stacklevel=2) return datetime.date(*map(int, val.split(b"-"))) def convert_timestamp(val): - warn(msg.format(what="converters"), DeprecationWarning, stacklevel=2) + warn(msg.format(what="timestamp converter"), DeprecationWarning, stacklevel=2) datepart, timepart = val.split(b" ") year, month, day = map(int, datepart.split(b"-")) timepart_full = timepart.split(b".") diff --git a/Lib/test/test_sqlite3/test_regression.py b/Lib/test/test_sqlite3/test_regression.py index 60501592484087..ad83a97c8c40d6 100644 --- a/Lib/test/test_sqlite3/test_regression.py +++ b/Lib/test/test_sqlite3/test_regression.py @@ -129,7 +129,7 @@ def test_type_map_usage(self): con = sqlite.connect(":memory:",detect_types=sqlite.PARSE_DECLTYPES) cur = con.cursor() cur.execute("create table foo(bar timestamp)") - with self.assertWarnsRegex(DeprecationWarning, "adapters"): + with self.assertWarnsRegex(DeprecationWarning, "adapter"): cur.execute("insert into foo(bar) values (?)", (datetime.datetime.now(),)) cur.execute(SELECT) cur.execute("drop table foo") @@ -306,7 +306,7 @@ def test_convert_timestamp_microsecond_padding(self): cur.execute("INSERT INTO t (x) VALUES ('2012-04-04 15:06:00.123456789')") cur.execute("SELECT * FROM t") - with self.assertWarnsRegex(DeprecationWarning, "converters"): + with self.assertWarnsRegex(DeprecationWarning, "converter"): values = [x[0] for x in cur.fetchall()] self.assertEqual(values, [ diff --git a/Lib/test/test_sqlite3/test_types.py b/Lib/test/test_sqlite3/test_types.py index 51c2e2432cde3a..62318823510d40 100644 --- a/Lib/test/test_sqlite3/test_types.py +++ b/Lib/test/test_sqlite3/test_types.py @@ -496,22 +496,22 @@ def tearDown(self): def test_sqlite_date(self): d = sqlite.Date(2004, 2, 14) - with self.assertWarnsRegex(DeprecationWarning, "adapters") as cm: + with self.assertWarnsRegex(DeprecationWarning, "adapter") as cm: self.cur.execute("insert into test(d) values (?)", (d,)) self.assertEqual(cm.filename, __file__) self.cur.execute("select d from test") - with self.assertWarnsRegex(DeprecationWarning, "converters") as cm: + with self.assertWarnsRegex(DeprecationWarning, "converter") as cm: d2 = self.cur.fetchone()[0] self.assertEqual(cm.filename, __file__) self.assertEqual(d, d2) def test_sqlite_timestamp(self): ts = sqlite.Timestamp(2004, 2, 14, 7, 15, 0) - with self.assertWarnsRegex(DeprecationWarning, "adapters") as cm: + with self.assertWarnsRegex(DeprecationWarning, "adapter") as cm: self.cur.execute("insert into test(ts) values (?)", (ts,)) self.assertEqual(cm.filename, __file__) self.cur.execute("select ts from test") - with self.assertWarnsRegex(DeprecationWarning, "converters") as cm: + with self.assertWarnsRegex(DeprecationWarning, "converter") as cm: ts2 = self.cur.fetchone()[0] self.assertEqual(cm.filename, __file__) self.assertEqual(ts, ts2) @@ -520,26 +520,26 @@ def test_sql_timestamp(self): now = datetime.datetime.utcnow() self.cur.execute("insert into test(ts) values (current_timestamp)") self.cur.execute("select ts from test") - with self.assertWarnsRegex(DeprecationWarning, "converters"): + with self.assertWarnsRegex(DeprecationWarning, "converter"): ts = self.cur.fetchone()[0] self.assertEqual(type(ts), datetime.datetime) self.assertEqual(ts.year, now.year) def test_date_time_sub_seconds(self): ts = sqlite.Timestamp(2004, 2, 14, 7, 15, 0, 500000) - with self.assertWarnsRegex(DeprecationWarning, "adapters"): + with self.assertWarnsRegex(DeprecationWarning, "adapter"): self.cur.execute("insert into test(ts) values (?)", (ts,)) self.cur.execute("select ts from test") - with self.assertWarnsRegex(DeprecationWarning, "converters"): + with self.assertWarnsRegex(DeprecationWarning, "converter"): ts2 = self.cur.fetchone()[0] self.assertEqual(ts, ts2) def test_date_time_sub_seconds_floating_point(self): ts = sqlite.Timestamp(2004, 2, 14, 7, 15, 0, 510241) - with self.assertWarnsRegex(DeprecationWarning, "adapters"): + with self.assertWarnsRegex(DeprecationWarning, "adapter"): self.cur.execute("insert into test(ts) values (?)", (ts,)) self.cur.execute("select ts from test") - with self.assertWarnsRegex(DeprecationWarning, "converters"): + with self.assertWarnsRegex(DeprecationWarning, "converter"): ts2 = self.cur.fetchone()[0] self.assertEqual(ts, ts2) 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