summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite
Commit message (Collapse)AuthorAgeFilesLines
* gh-140042: Removing unsafe call to sqlite3_shutdown (GH-141690)Prithviraj Chaudhuri2025-11-201-1/+0
|
* gh-139327: consolidate `sqlite3_finalize` and `sqlite3_reset` usages (GH-139329)Bénédikt Tran2025-10-155-16/+113
|
* gh-138342: Move _PyObject_VisitType() to the internal C API (#139734)Victor Stinner2025-10-082-0/+14
|
* gh-139327: fix some reference leaks in `sqlite3` error branches (#139328)Bénédikt Tran2025-10-012-32/+42
|
* gh-139283: correctly handle `size` limit in `cursor.fetchmany()` (#139296)Bénédikt Tran2025-09-303-18/+85
| | | | | | | | Passing a negative or zero size to `cursor.fetchmany()` made it fetch all rows instead of none. While this could be considered a security vulnerability, it was decided to treat this issue as a regular bug as passing a non-sanitized *size* value in the first place is not recommended.
* gh-129813, PEP 782: Use PyBytesWriter in _sqlite (#138956)Victor Stinner2025-09-181-14/+19
| | | | Replace PyBytes_FromStringAndSize(NULL, size) with the new public PyBytesWriter API.
* gh-138736: Fix sqlite3.Connection.blobopen 'row' parameter type and naming ↵chiri2025-09-172-7/+7
| | | | | (#138738) The 'row' parameter represents a ROWID. Clarify this in docs and docstrings.
* gh-138342: Use a common utility for visiting an object's type (GH-138343)Peter Bierma2025-09-012-16/+2
| | | Add `_PyObject_VisitType` in place of `tp_traverse` functions that only visit the object's type.
* GH-137623: Use an AC decorator for docstring line length enforcement (#137690)Adam Turner2025-08-182-7/+14
|
* gh-135607: remove null checking of weakref list in dealloc of extension ↵Xuanteng Huang2025-06-302-6/+4
| | | | | | modules and objects (#135614) Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-133390: Support SQL keyword completion for sqlite3 CLI (GH-133393) ↵Petr Viktorin2025-06-121-0/+39
| | | | | (GH-135292) Co-authored-by: Tan Long <tanloong@foxmail.com>
* Revert "gh-133390: Support SQL keyword completion for sqlite3 CLI (#133393)" ↵Petr Viktorin2025-06-071-39/+0
| | | | | | temporarily (GH-135232) This reverts commit 62b3d2d443785c4ea5262edb4f9f7040440f9463, which broke buildbots
* gh-133390: Support SQL keyword completion for sqlite3 CLI (#133393)Tan Long2025-06-061-0/+39
|
* gh-133595: Clean up sqlite3.Connection APIs (GH-133605)Serhiy Storchaka2025-05-084-280/+62
| | | | | | | | * All parameters of sqlite3.connect() except "database" are now keyword-only. * The first three parameters of methods create_function() and create_aggregate() are now positional-only. * The first parameter of methods set_authorizer(), set_progress_handler() and set_trace_callback() is now positional-only.
* gh-131525: Cache the result of tuple_hash (#131529)Michael Droettboom2025-03-273-3/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gh-131525: Cache the result of tuple_hash * Fix debug builds * Add blurb * Fix formatting * Pre-compute empty tuple singleton * Mostly set the cache within tuple_alloc * Fixes for TSAN * Pre-compute empty tuple singleton * Fix for 32-bit platforms * Assert that op != NULL in _PyTuple_RESET_HASH_CACHE * Use FT_ATOMIC_STORE_SSIZE_RELAXED macro * Update Include/internal/pycore_tuple.h Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * Fix alignment * atomic load * Update Objects/tupleobject.c Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com> --------- Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
* GH-131238: More refactoring of core header files (GH-131351)Mark Shannon2025-03-171-0/+1
| | | | Adds new pycore_stats.h header file to help break dependencies involving the pycore_code.h header.
* gh-111178: Change Argument Clinic signature for METH_O (#130682)Victor Stinner2025-03-114-7/+34
| | | Use "PyObject*" for METH_O functions to fix an undefined behavior.
* gh-129928: Rework sqlite3 error helpers (#129929)Erlend E. Aasland2025-02-116-30/+41
| | | | | | | | | Add a helper for raising DB-API compatible exceptions based on the result code of SQLite C APIs. Some APIs do not store the error indicator on the database pointer, so we need to be able to deduce the DB-API compatible exception directly from the error code. - rename _pysqlite_seterror() as set_error_from_db() - introduce set_error_from_code()
* gh-129928: Raise more accurate exception for incorrect sqlite3 UDF creation ↵Erlend E. Aasland2025-02-111-1/+23
| | | | | | (#129941) Consistently raise ProgrammingError if the user tries to create an UDF with an invalid number of parameters.
* gh-129603: Don't segfault if sqlite3.Row description is None (#129604)Erlend E. Aasland2025-02-091-10/+15
|
* gh-129354: Use PyErr_FormatUnraisable() function (#129524)Victor Stinner2025-02-031-3/+6
| | | | | | | Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable(). Update test_sqlite3 tests. Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-111178: fix UBSan failures in `Modules/_sqlite` (GH-129087)Bénédikt Tran2025-01-317-55/+101
| | | | | | | | | | | * fix UBSan failures for `pysqlite_Blob` * fix UBSan failures for `pysqlite_Connection` * fix UBSan failures for `pysqlite_Cursor` * fix UBSan failures for `pysqlite_PrepareProtocol` * fix UBSan failures for `pysqlite_Row` * fix UBSan failures for `pysqlite_Statement` * suppress unused return values
* gh-128911: Add PyImport_ImportModuleAttr() function (#128912)Victor Stinner2025-01-302-5/+2
| | | | | | | | | | | Add PyImport_ImportModuleAttr() and PyImport_ImportModuleAttrString() functions. * Add unit tests. * Replace _PyImport_GetModuleAttr() with PyImport_ImportModuleAttr(). * Replace _PyImport_GetModuleAttrString() with PyImport_ImportModuleAttrString(). * Remove "pycore_import.h" includes, no longer needed.
* gh-129346: Handle allocation errors for SQLite aggregate context (#129347)Erlend E. Aasland2025-01-271-0/+5
|
* gh-111178: Generate correct signature for most self converters (#128447)Erlend E. Aasland2025-01-205-93/+93
|
* gh-126742: Add _PyErr_SetLocaleString, use it for gdbm & dlerror messages ↵Bénédikt Tran2024-12-171-0/+1
| | | | | | | | (GH-126746) - Add a helper to set an error from locale-encoded `char*` - Use the helper for gdbm & dlerror messages Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-122943: Add the varpos parameter in _PyArg_UnpackKeywords (GH-126564)Serhiy Storchaka2024-11-083-20/+37
| | | | Remove _PyArg_UnpackKeywordsWithVararg. Add comments for integer arguments of _PyArg_UnpackKeywords.
* Fixes loop variables to be the same types as their limit (GH-120958)Steve Dower2024-06-241-1/+1
|
* gh-113993: Allow interned strings to be mortal, and fix related issues ↵Petr Viktorin2024-06-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-120520) * Add an InternalDocs file describing how interning should work and how to use it. * Add internal functions to *explicitly* request what kind of interning is done: - `_PyUnicode_InternMortal` - `_PyUnicode_InternImmortal` - `_PyUnicode_InternStatic` * Switch uses of `PyUnicode_InternInPlace` to those. * Disallow using `_Py_SetImmortal` on strings directly. You should use `_PyUnicode_InternImmortal` instead: - Strings should be interned before immortalization, otherwise you're possibly interning a immortalizing copy. - `_Py_SetImmortal` doesn't handle the `SSTATE_INTERNED_MORTAL` to `SSTATE_INTERNED_IMMORTAL` update, and those flags can't be changed in backports, as they are now part of public API and version-specific ABI. * Add private `_only_immortal` argument for `sys.getunicodeinternedsize`, used in refleak test machinery. * Make sure the statically allocated string singletons are unique. This means these sets are now disjoint: - `_Py_ID` - `_Py_STR` (including the empty string) - one-character latin-1 singletons Now, when you intern a singleton, that exact singleton will be interned. * Add a `_Py_LATIN1_CHR` macro, use it instead of `_Py_ID`/`_Py_STR` for one-character latin-1 singletons everywhere (including Clinic). * Intern `_Py_STR` singletons at startup. * For free-threaded builds, intern `_Py_LATIN1_CHR` singletons at startup. * Beef up the tests. Cover internal details (marked with `@cpython_only`). * Add lots of assertions Co-Authored-By: Eric Snow <ericsnowcurrently@gmail.com>
* gh-118928: sqlite3: correctly bail if sequences of params are used with ↵Erlend E. Aasland2024-05-201-0/+1
| | | | named placeholders (#119197)
* gh-118928: sqlite3: disallow sequences of params with named placeholders ↵Erlend E. Aasland2024-05-141-6/+2
| | | | | | | | (#118929) Follow-up of gh-101693. The previous DeprecationWarning is replaced with raising sqlite3.ProgrammingError. Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* gh-118924: Remove `sqlite3.version` and `sqlite3.version_info` (#118925)Hugo van Kemenade2024-05-101-4/+0
|
* gh-116322: Add Py_mod_gil module slot (#116882)Brett Simmers2024-05-031-0/+1
| | | | | | | | | | | | | | This PR adds the ability to enable the GIL if it was disabled at interpreter startup, and modifies the multi-phase module initialization path to enable the GIL when loading a module, unless that module's spec includes a slot indicating it can run safely without the GIL. PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148. A warning will be issued up to once per interpreter for the first GIL-using module that is loaded. If `-v` is given, a shorter message will be printed to stderr every time a GIL-using module is loaded (including the first one that issues a warning).
* gh-118406: Add signature for sqlite3.Connection objects (#118428)Erlend E. Aasland2024-04-301-0/+7
|
* gh-117995: Don't raise DeprecationWarnings for indexed nameless params (#118001)Erlend E. Aasland2024-04-221-1/+1
| | | | | Filter out '?NNN' placeholders when looking for named params. Co-authored-by: AN Long <aisk@users.noreply.github.com>
* gh-117613: Argument Clinic: ensure that 'defining_class' params are ↵neonene2024-04-161-4/+4
| | | | positional-only (#117781)
* gh-111926: Make weakrefs thread-safe in free-threaded builds (#117168)mpage2024-04-082-5/+4
| | | | | | | | | Most mutable data is protected by a striped lock that is keyed on the referenced object's address. The weakref's hash is protected using the weakref's per-object lock. Note that this only affects free-threaded builds. Apart from some minor refactoring, the added code is all either gated by `ifdef`s or is a no-op (e.g. `Py_BEGIN_CRITICAL_SECTION`).
* gh-111140: Adds PyLong_AsNativeBytes and PyLong_FromNative[Unsigned]Bytes ↵Steve Dower2024-02-121-1/+1
| | | | functions (GH-114886)
* gh-91602: Add iterdump() support for filtering database objects (#114501)Mariusz Felisiak2024-02-062-11/+69
| | | | | | Add optional 'filter' parameter to iterdump() that allows a "LIKE" pattern for filtering database objects to dump. Co-authored-by: Erlend E. Aasland <erlend@python.org>
* gh-115026: Argument Clinic: handle PyBuffer_FillInfo errors in generated ↵Nikita Sobolev2024-02-051-2/+4
| | | | code (#115027)
* gh-111789: Simplify the sqlite code (GH-111829)Serhiy Storchaka2023-11-102-17/+6
| | | | Use new C API functions PyDict_GetItemRef() and PyMapping_GetOptionalItemString().
* Add private _PyUnicode_AsUTF8NoNUL() function (GH-111957)Serhiy Storchaka2023-11-101-7/+1
| | | | Like PyUnicode_AsUTF8(), but check for embedded null characters.
* gh-111089: Revert PyUnicode_AsUTF8() changes (#111833)Victor Stinner2023-11-074-18/+93
| | | | | | | | | | | | | | | | | | | | | * Revert "gh-111089: Use PyUnicode_AsUTF8() in Argument Clinic (#111585)" This reverts commit d9b606b3d04fc56fb0bcc479d7d6c14562edb5e2. * Revert "gh-111089: Use PyUnicode_AsUTF8() in getargs.c (#111620)" This reverts commit cde1071b2a72e8261ca66053ef61431b7f3a81fd. * Revert "gh-111089: PyUnicode_AsUTF8() now raises on embedded NUL (#111091)" This reverts commit d731579bfb9a497cfb0076cb6b221058a20088fe. * Revert "gh-111089: Add PyUnicode_AsUTF8() to the limited C API (#111121)" This reverts commit d8f32be5b6a736dc2fc9dca3f1bf176c82fc9b44. * Revert "gh-111089: Use PyUnicode_AsUTF8() in sqlite3 (#111122)" This reverts commit 37e4e20eaa8f27ada926d49e5971fecf0477ad26.
* gh-111089: Use PyUnicode_AsUTF8() in Argument Clinic (#111585)Victor Stinner2023-11-013-87/+17
| | | | | | | Replace PyUnicode_AsUTF8AndSize() with PyUnicode_AsUTF8() to remove the explicit check for embedded null characters. The change avoids to have to include explicitly <string.h> to get the strlen() function when using a recent version of the limited C API.
* gh-67565: Remove redundant C-contiguity checks (GH-105521)Furkan Onder2023-10-232-10/+2
| | | | Co-authored-by: Stefan Krah <skrah@bytereef.org>
* gh-111089: Use PyUnicode_AsUTF8() in sqlite3 (#111122)Victor Stinner2023-10-201-6/+1
| | | | PyUnicode_AsUTF8() now raises an exception if the string contains embedded null characters.
* gh-110964: Remove private _PyArg functions (#110966)Victor Stinner2023-10-178-6/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the following private functions and structures to pycore_modsupport.h internal C API: * _PyArg_BadArgument() * _PyArg_CheckPositional() * _PyArg_NoKeywords() * _PyArg_NoPositional() * _PyArg_ParseStack() * _PyArg_ParseStackAndKeywords() * _PyArg_Parser structure * _PyArg_UnpackKeywords() * _PyArg_UnpackKeywordsWithVararg() * _PyArg_UnpackStack() * _Py_ANY_VARARGS() Changes: * Python/getargs.h now includes pycore_modsupport.h to export functions. * clinic.py now adds pycore_modsupport.h when one of these functions is used. * Add pycore_modsupport.h includes when a C extension uses one of these functions. * Define Py_BUILD_CORE_MODULE in C extensions which now include directly or indirectly (via code generated by Argument Clinic) pycore_modsupport.h: * _csv * _curses_panel * _dbm * _gdbm * _multiprocessing.posixshmem * _sqlite.row * _statistics * grp * resource * syslog * _testcapi: bad_get() no longer uses METH_FASTCALL calling convention but METH_VARARGS. Replace _PyArg_UnpackStack() with PyArg_ParseTuple(). * _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined by _testcapi sub-modules which need the internal C API (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c, watchers.c. * Remove Include/cpython/modsupport.h header file. Include/modsupport.h no longer includes the removed header file. * Fix mypy clinic.py
* gh-107603: Argument Clinic: Only include pycore_gc.h if needed (#108726)Victor Stinner2023-08-316-30/+14
| | | | | | | | | | | | | | | | | | | | Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. * Add 'condition' optional argument to Clinic.add_include(). * deprecate_keyword_use() includes pycore_runtime.h when using the _PyID() function. * Fix rendering of includes: comments start at the column 35. * Mark PC/clinic/_wmimodule.cpp.h and "Objects/stringlib/clinic/*.h.h" header files as generated in .gitattributes. Effects: * 42 header files generated by AC no longer include the internal C API, instead of 4 header files before. For example, Modules/clinic/_abc.c.h no longer includes the internal C API. * Fix _testclinic_depr.c.h: it now always includes pycore_runtime.h to get _Py_ID().
* gh-106320: Remove private _PyErr_ChainExceptions() (#108713)Victor Stinner2023-08-311-0/+2
| | | | | | | | | | | | | Remove _PyErr_ChainExceptions(), _PyErr_ChainExceptions1() and _PyErr_SetFromPyStatus() functions from the public C API. * Move the private _PyErr_ChainExceptions() and _PyErr_ChainExceptions1() function to the internal C API (pycore_pyerrors.h). * Move the private _PyErr_SetFromPyStatus() to the internal C API (pycore_initconfig.h). * No longer export the _PyErr_ChainExceptions() function. * Move run_in_subinterp_with_config() from _testcapi to _testinternalcapi.
* gh-108278: Deprecate passing the first param of sqlite3.Connection callback ↵Erlend E. Aasland2023-08-292-16/+111
| | | | | | | | | | | | APIs by keyword (#108632) Deprecate passing the callback callable by keyword for the following sqlite3.Connection APIs: - set_authorizer(authorizer_callback) - set_progress_handler(progress_handler, ...) - set_trace_callback(trace_callback) The affected parameters will become positional-only in Python 3.15.