gh-90016: Deprecate default sqlite3 adapters and converters (#94276)

Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
This commit is contained in:
Erlend Egeberg Aasland 2022-07-20 21:37:59 +02:00 committed by GitHub
parent 000a4eebe7
commit 6dadf6ca01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 66 additions and 49 deletions

View file

@ -55,16 +55,25 @@ Binary = memoryview
collections.abc.Sequence.register(Row)
def register_adapters_and_converters():
from warnings import warn
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="date adapter"), DeprecationWarning, stacklevel=2)
return val.isoformat()
def adapt_datetime(val):
warn(msg.format(what="datetime adapter"), DeprecationWarning, stacklevel=2)
return val.isoformat(" ")
def convert_date(val):
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="timestamp converter"), DeprecationWarning, stacklevel=2)
datepart, timepart = val.split(b" ")
year, month, day = map(int, datepart.split(b"-"))
timepart_full = timepart.split(b".")