bpo-40956: Use Argument Clinic in sqlite3 module by erlend-aasland · Pull Request #20826 · python/cpython
I've updated the PR and fixed the following:
- Only apply Argument Clinic (don't change parameter names, variable names, any other code)
- Apply AC to all methods and function (even
prepare_protocol.c) - Fixed all ref. leaks (Checked with
./python.exe -m test -F -r -j1 -R 3:10 test_sqlite)
Note 1: I've used _PyObject_CallMethodId* iso. pysqlite_cache_get() (fc89d4c853c498b8e51edd6787bdb8bcacd7279c) and pysqlite_connection_commit() (f646fdebfc810b30fc122922f0230e1b8b0d78c0), and iso. the cursor.execute* calls in connection.c (f646fdebfc810b30fc122922f0230e1b8b0d78c0). AFAICS, that should be an acceptable and clean solution.
Note 2: Converting _sqlite3.connect and _sqlite3.Connection.__init__ is not trivial. The "best" solution I could come up with (without recreating args and kwargs) was to use PyObject_CallFunctionObjArgs. However, then I need to ensure that none of the arguments are NULL, so I had to copy parts of the isolation_level code from connection.c. Very ugly. I'm sure there's a better way to do this, but I don't know the C API good enough to come up with a better solution right now. (One solution is of course to revert commit 0b456f1c08d879833be6c9d5b161bbc688defe60 ...)
PS. Sorry for force-pushing again. I'll try to avoid it.