You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python3.11: sqlite3.connect passes more arguments to factory() #95132
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:
Thanks for the report. This is unfortunate. Reverting the offending commit is going to be hairy; there has been a lot of changes since that point in time.
The only thing sqlite3.connect needs in order to relay the call to sqlite3.Connection.__init__ is: *args, **kwargs, and factory. Unfortunately, doing such a manoeuvre is impossible (AFAIK) with Argument Clinic. Trying to bend AC to our needs, could be an option. Another option is to just parse the factory argument manually (kinda like the old code), and pass the rest using vector call (or PyObject_Call). I've already tried to look for a way to do these things because of keyword-only argument needs in another PR (#93823); I might actually be able to adopt that approach.
I've already tried to look for a way to do these things because of keyword-only argument needs in another PR (#93823); I might actually be able to adopt that approach.
FTR, this won't work. Arguments will still be passed incorrectly.
Activity
erlend-aasland commentedon Jul 22, 2022
Thanks for the report. This is unfortunate. Reverting the offending commit is going to be hairy; there has been a lot of changes since that point in time.
The only thing
sqlite3.connectneeds in order to relay the call tosqlite3.Connection.__init__is:*args,**kwargs, andfactory. Unfortunately, doing such a manoeuvre is impossible (AFAIK) with Argument Clinic. Trying to bend AC to our needs, could be an option. Another option is to just parse thefactoryargument manually (kinda like the old code), and pass the rest using vector call (orPyObject_Call). I've already tried to look for a way to do these things because of keyword-only argument needs in another PR (#93823); I might actually be able to adopt that approach.@serhiy-storchaka, do you have an opinion here?
Thanks again for testing the 3.11 beta! Reports like this help us improve.
erlend-aasland commentedon Jul 22, 2022
FTR, this won't work. Arguments will still be passed incorrectly.
[alt 1] pythongh-95132: partially revert 185ecdc
erlend-aasland commentedon Jul 22, 2022
I've partially reverted 185ecdc in #95146.
[alt 2] pythongh-95132: use vectorcall
erlend-aasland commentedon Jul 22, 2022
I've updated #95146 to use
METH_FASTCALLandPyObject_Vectorcall.gh-95132: Correctly relay *args and **kwds from sqlite3.connect to fa…
[3.11] pythongh-95132: Correctly relay *args and **kwds from sqlite3.…
erlend-aasland commentedon Jul 23, 2022
Fixed in:
[3.11] gh-95132: Correctly relay *args and **kwds from sqlite3.connec…
vstinner commentedon Aug 1, 2022
Nice fix.