Skip to content

Commit 46c7ccf

Browse files
authored
Fix DeprecationWarning on 3.12 with a datetime adapter for sqlite3 (#14139)
After python/cpython#90016, default adapters and converters are deprecated. See also https://docs.python.org/3.12/library/sqlite3.html#sqlite3-adapter-converter-recipes
2 parents 175d52c + e1a3ce3 commit 46c7ccf

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

IPython/core/history.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,17 +574,23 @@ def new_session(self, conn=None):
574574
cur = conn.execute(
575575
"""INSERT INTO sessions VALUES (NULL, ?, NULL,
576576
NULL, '') """,
577-
(datetime.datetime.now(),),
577+
(datetime.datetime.now().isoformat(" "),),
578578
)
579579
self.session_number = cur.lastrowid
580580

581581
def end_session(self):
582582
"""Close the database session, filling in the end time and line count."""
583583
self.writeout_cache()
584584
with self.db:
585-
self.db.execute("""UPDATE sessions SET end=?, num_cmds=? WHERE
586-
session==?""", (datetime.datetime.now(),
587-
len(self.input_hist_parsed)-1, self.session_number))
585+
self.db.execute(
586+
"""UPDATE sessions SET end=?, num_cmds=? WHERE
587+
session==?""",
588+
(
589+
datetime.datetime.now().isoformat(" "),
590+
len(self.input_hist_parsed) - 1,
591+
self.session_number,
592+
),
593+
)
588594
self.session_number = 0
589595

590596
def name_session(self, name):

IPython/core/logger.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import time
2121

2222

23-
2423
# prevent jedi/parso's debug messages pipe into interactiveshell
2524
logging.getLogger("parso").setLevel(logging.WARNING)
2625

0 commit comments

Comments
 (0)