Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 222c63f

Browse files
gh-103015: Add entrypoint keyword param to sqlite3.Connection.load_extension (#103073)
1 parent 28a05f4 commit 222c63f

9 files changed

+104
-14
lines changed

Doc/library/sqlite3.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,19 +1041,37 @@ Connection objects
10411041
(2, 'broccoli pie', 'broccoli cheese onions flour')
10421042
(3, 'pumpkin pie', 'pumpkin sugar flour butter')
10431043

1044-
.. method:: load_extension(path, /)
1044+
.. method:: load_extension(path, /, *, entrypoint=None)
10451045

1046-
Load an SQLite extension from a shared library located at *path*.
1046+
Load an SQLite extension from a shared library.
10471047
Enable extension loading with :meth:`enable_load_extension` before
10481048
calling this method.
10491049

1050+
:param str path:
1051+
1052+
The path to the SQLite extension.
1053+
1054+
:param entrypoint:
1055+
1056+
Entry point name.
1057+
If ``None`` (the default),
1058+
SQLite will come up with an entry point name of its own;
1059+
see the SQLite docs `Loading an Extension`_ for details.
1060+
1061+
:type entrypoint: str | None
1062+
10501063
.. audit-event:: sqlite3.load_extension connection,path sqlite3.Connection.load_extension
10511064

10521065
.. versionadded:: 3.2
10531066

10541067
.. versionchanged:: 3.10
10551068
Added the ``sqlite3.load_extension`` auditing event.
10561069

1070+
.. versionadded:: 3.12
1071+
The *entrypoint* parameter.
1072+
1073+
.. _Loading an Extension: https://www.sqlite.org/loadext.html#loading_an_extension_
1074+
10571075
.. method:: iterdump
10581076

10591077
Return an :term:`iterator` to dump the database as SQL source code.

Doc/whatsnew/3.12.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,11 @@ sqlite3
406406
:ref:`transaction handling <sqlite3-transaction-control-autocommit>`.
407407
(Contributed by Erlend E. Aasland in :gh:`83638`.)
408408

409+
* Add *entrypoint* keyword-only parameter to
410+
:meth:`~sqlite3.Connection.load_extension`,
411+
for overriding the SQLite extension entry point.
412+
(Contributed by Erlend E. Aasland in :gh:`103015`.)
413+
409414
threading
410415
---------
411416

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ struct _Py_global_strings {
378378
STRUCT_FOR_ID(end_lineno)
379379
STRUCT_FOR_ID(end_offset)
380380
STRUCT_FOR_ID(endpos)
381+
STRUCT_FOR_ID(entrypoint)
381382
STRUCT_FOR_ID(env)
382383
STRUCT_FOR_ID(errors)
383384
STRUCT_FOR_ID(event)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Add *entrypoint* keyword-only parameter to
2+
:meth:`sqlite3.Connection.load_extension`, for overriding the SQLite
3+
extension entry point. Patch by Erlend E. Aasland.

Modules/_sqlite/clinic/connection.c.h

Lines changed: 64 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_sqlite/connection.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,14 +1601,17 @@ _sqlite3.Connection.load_extension as pysqlite_connection_load_extension
16011601
16021602
name as extension_name: str
16031603
/
1604+
*
1605+
entrypoint: str(accept={str, NoneType}) = None
16041606
16051607
Load SQLite extension module.
16061608
[clinic start generated code]*/
16071609

16081610
static PyObject *
16091611
pysqlite_connection_load_extension_impl(pysqlite_Connection *self,
1610-
const char *extension_name)
1611-
/*[clinic end generated code: output=47eb1d7312bc97a7 input=edd507389d89d621]*/
1612+
const char *extension_name,
1613+
const char *entrypoint)
1614+
/*[clinic end generated code: output=7e61a7add9de0286 input=c36b14ea702e04f5]*/
16121615
{
16131616
int rc;
16141617
char* errmsg;
@@ -1621,7 +1624,7 @@ pysqlite_connection_load_extension_impl(pysqlite_Connection *self,
16211624
return NULL;
16221625
}
16231626

1624-
rc = sqlite3_load_extension(self->db, extension_name, 0, &errmsg);
1627+
rc = sqlite3_load_extension(self->db, extension_name, entrypoint, &errmsg);
16251628
if (rc != 0) {
16261629
PyErr_SetString(self->OperationalError, errmsg);
16271630
return NULL;

0 commit comments

Comments
 (0)