From 0fe66bd3d98267cce06edf1594bf5627a555777c Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 11 Aug 2025 09:16:54 +0300 Subject: [PATCH] Add test for opening an SQLite with bytes path (GH-136331) (cherry picked from commit 1bde13b0e99592fbfce3538b27ada29ea09840a6) Co-authored-by: Serhiy Storchaka --- Lib/test/test_sqlite3/test_dbapi.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py index 0ef05ff1929b24..d95f5fde0e0f50 100644 --- a/Lib/test/test_sqlite3/test_dbapi.py +++ b/Lib/test/test_sqlite3/test_dbapi.py @@ -638,6 +638,14 @@ def test_deserialize_corrupt_database(self): class OpenTests(unittest.TestCase): _sql = "create table test(id integer)" + def test_open_with_bytes_path(self): + path = os.fsencode(TESTFN) + self.addCleanup(unlink, path) + self.assertFalse(os.path.exists(path)) + with contextlib.closing(sqlite.connect(path)) as cx: + self.assertTrue(os.path.exists(path)) + cx.execute(self._sql) + def test_open_with_path_like_object(self): """ Checks that we can successfully connect to a database using an object that is PathLike, i.e. has __fspath__(). """