Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Python3.11: sqlite3.connect passes more arguments to factory() #95132

Closed
Assignees
erlend-aasland
Labels
3.11only security fixes3.12only security fixestopic-sqlite3triagedThe issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or error
@Steap

Description

@Steap

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

Labels

3.11only security fixes3.12only security fixestopic-sqlite3triagedThe issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or error

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp