Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Hello,
Bug report
Consider the following code snippet:
$ cat /tmp/test.py
importsqlite3classSqliteConnection(sqlite3.Connection):def__init__(self,*args,**kwargs):print(args)print(kwargs)super(SqliteConnection,self).__init__(*args,**kwargs)db_path='/tmp/foo.db'sqlite3.connect(db_path,factory=SqliteConnection)
And the execution:
$ python3.10 /tmp/test.py('/tmp/foo.db',){'factory':<class'__main__.SqliteConnection'>}$ python3.11 /tmp/test.py('/tmp/foo.db', 5.0, 0,'', 1,<class'__main__.SqliteConnection'>, 128, 0){}
The default values of sqlite3.connect's arguments are passed to the factory in
Python3.11, which was not the case in Python3.10. This means that code like
this will fail:
$ cat /tmp/failure.py
importsqlite3classSqliteConnection(sqlite3.Connection):def__init__(self,*args,**kwargs):kwargs['timeout']=42super(SqliteConnection,self).__init__(*args,**kwargs)db_path='/tmp/foo.db'sqlite3.connect(db_path,factory=SqliteConnection)
$ python3.10 /tmp/failure.py$$ python3.11 /tmp/failure.pyTraceback (most recent call last): File"/tmp/failure.py", line 11,in<module> sqlite3.connect(db_path, factory=SqliteConnection) File"/tmp/failure.py", line 7,in __init__ super(SqliteConnection, self).__init__(*args,**kwargs)TypeError:Connection() takes at most 8 arguments (9 given)
Your environment
This behaviour appeared in185ecdc and affects
Python 3.11 and later.
It was mentioned in#93044 (see the
second bullet point in the reporter's message) but has not been fixed.
Metadata
Metadata
Assignees
Labels
Projects
Status
Done