mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
[3.11] gh-93044: No longer convert the database argument of sqlite3.connect() to bytes (GH-93046) (GH-93048)
Just pass it to the factory as is.
(cherry picked from commit 14c0d33016
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
f2aeb3f6f7
commit
d9a48d2b41
4 changed files with 19 additions and 7 deletions
|
@ -685,6 +685,19 @@ class OpenTests(unittest.TestCase):
|
|||
with managed_connect(f"file:{TESTFN}?mode=ro", uri=True) as cx:
|
||||
cx.execute(self._sql)
|
||||
|
||||
def test_factory_database_arg(self):
|
||||
def factory(database, *args, **kwargs):
|
||||
nonlocal database_arg
|
||||
database_arg = database
|
||||
return sqlite.Connection(":memory:", *args, **kwargs)
|
||||
|
||||
for database in (TESTFN, os.fsencode(TESTFN),
|
||||
FakePath(TESTFN), FakePath(os.fsencode(TESTFN))):
|
||||
database_arg = None
|
||||
with sqlite.connect(database, factory=factory):
|
||||
pass
|
||||
self.assertEqual(database_arg, database)
|
||||
|
||||
def test_database_keyword(self):
|
||||
with sqlite.connect(database=":memory:") as cx:
|
||||
self.assertEqual(type(cx), sqlite.Connection)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue