[pypy-commit] pypy default: _sqlite3.connect accepts positional arguments. Copy the interface of Connection.__init__ :/

bivab noreply at buildbot.pypy.org
Sat Sep 28 13:57:48 CEST 2013


Author: David Schneider <david.schneider at picle.org>
Branch: 
Changeset: r67124:c9f9979e0eed
Date: 2013-09-28 13:57 +0200
http://bitbucket.org/pypy/pypy/changeset/c9f9979e0eed/

Log:	_sqlite3.connect accepts positional arguments. Copy the interface of
	Connection.__init__ :/

diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -363,9 +363,11 @@
     pass
 
 
-def connect(database, **kwargs):
-    factory = kwargs.get("factory", Connection)
-    return factory(database, **kwargs)
+def connect(database, timeout=5.0, detect_types=0, isolation_level="",
+                 check_same_thread=True, factory=None, cached_statements=100):
+    factory = Connection if not factory else factory
+    return factory(database, timeout, detect_types, isolation_level,
+                    check_same_thread, factory, cached_statements)
 
 
 def _unicode_text_factory(x):
diff --git a/pypy/module/test_lib_pypy/test_sqlite3.py b/pypy/module/test_lib_pypy/test_sqlite3.py
--- a/pypy/module/test_lib_pypy/test_sqlite3.py
+++ b/pypy/module/test_lib_pypy/test_sqlite3.py
@@ -31,6 +31,12 @@
     result = list(cursor)
     assert result == [(42,)]
 
+def test_connect_takes_same_positional_args_as_Connection(con):
+    from inspect import getargspec
+    clsargs = getargspec(_sqlite3.Connection.__init__).args[1:]  # ignore self
+    conargs = getargspec(_sqlite3.connect).args
+    assert clsargs == conargs
+
 def test_total_changes_after_close(con):
     con.close()
     pytest.raises(_sqlite3.ProgrammingError, "con.total_changes")


More information about the pypy-commit mailing list