Skip to content

Commit 82cf3e2

Browse files
Address Serhiy's review
- revert most argument spec changes - align argument spec across docstrings/docs - improve wording of register_adapter/register_converter - undo note
1 parent 40bb59a commit 82cf3e2

File tree

3 files changed

+36
-37
lines changed

3 files changed

+36
-37
lines changed

Doc/library/sqlite3.rst

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -318,23 +318,22 @@ Module functions and constants
318318
Added the ``sqlite3.connect/handle`` auditing event.
319319

320320

321-
.. function:: register_converter(type, callable)
321+
.. function:: register_converter(typename, converter)
322322

323-
Register *callable* to convert SQLite *type* into a Python type.
324-
*callable* is invoked for all values of type *typename*.
325-
Confer the parameter *detect_types* of :meth:`Connection.connect`
326-
regarding how type detection works.
323+
Register callable *converter* to convert SQLite type name *typename* into a
324+
Python type. The converter is invoked for all SQLite values of type
325+
*typename*. Confer the parameter *detect_types* of
326+
:meth:`Connection.connect` regarding how type detection works.
327327

328-
.. note::
329-
*type* and the name of the type in your query are matched in a
330-
case-insensitive manner.
328+
Note: *typename* and the name of the type in your query are matched in a
329+
case-insensitive manner.
331330

332331

333-
.. function:: register_adapter(type, callable)
332+
.. function:: register_adapter(type, adapter)
334333

335-
Register *callable* to adapt Python *type* into an SQLite type.
336-
*callable* is called with the Python value and must return a valid SQLite
337-
type:
334+
Register callable *adapter* to adapt Python type *type* into an SQLite type.
335+
The adapter is called with a Python object as its sole argument,
336+
and must return a valid SQLite type:
338337
:class:`int`, :class:`float`, :class:`str`, :class:`bytes`, or :const:`None`.
339338

340339

Modules/_sqlite/clinic/module.c.h

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

Modules/_sqlite/module.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,16 @@ pysqlite_complete_statement_impl(PyObject *module, const char *statement)
108108
_sqlite3.register_adapter as pysqlite_register_adapter
109109
110110
type: object(type='PyTypeObject *')
111-
callable as adapter: object
111+
adapter as caster: object
112112
/
113113
114114
Register a function to adapt Python types to SQLite types.
115115
[clinic start generated code]*/
116116

117117
static PyObject *
118118
pysqlite_register_adapter_impl(PyObject *module, PyTypeObject *type,
119-
PyObject *adapter)
120-
/*[clinic end generated code: output=83bab29ff572feb4 input=b6813f5d620955ed]*/
119+
PyObject *caster)
120+
/*[clinic end generated code: output=a287e8db18e8af23 input=f96c4fb2beba002b]*/
121121
{
122122
int rc;
123123

@@ -131,7 +131,7 @@ pysqlite_register_adapter_impl(PyObject *module, PyTypeObject *type,
131131

132132
pysqlite_state *state = pysqlite_get_state(module);
133133
PyObject *protocol = (PyObject *)state->PrepareProtocolType;
134-
rc = pysqlite_microprotocols_add(state, type, protocol, adapter);
134+
rc = pysqlite_microprotocols_add(state, type, protocol, caster);
135135
if (rc == -1) {
136136
return NULL;
137137
}
@@ -142,29 +142,29 @@ pysqlite_register_adapter_impl(PyObject *module, PyTypeObject *type,
142142
/*[clinic input]
143143
_sqlite3.register_converter as pysqlite_register_converter
144144
145-
type as tp: unicode
146-
callable as converter: object
145+
typename as orig_name: unicode
146+
converter as callable: object
147147
/
148148
149149
Register a function to convert SQLite types to Python types.
150150
[clinic start generated code]*/
151151

152152
static PyObject *
153-
pysqlite_register_converter_impl(PyObject *module, PyObject *tp,
154-
PyObject *converter)
155-
/*[clinic end generated code: output=59b8c05cdddf7e54 input=63d20a7be9873f12]*/
153+
pysqlite_register_converter_impl(PyObject *module, PyObject *orig_name,
154+
PyObject *callable)
155+
/*[clinic end generated code: output=a2f2bfeed7230062 input=138f93f0063cb031]*/
156156
{
157157
PyObject* name = NULL;
158158
PyObject* retval = NULL;
159159

160160
/* convert the name to upper case */
161161
pysqlite_state *state = pysqlite_get_state(module);
162-
name = PyObject_CallMethodNoArgs(tp, state->str_upper);
162+
name = PyObject_CallMethodNoArgs(orig_name, state->str_upper);
163163
if (!name) {
164164
goto error;
165165
}
166166

167-
if (PyDict_SetItem(state->converters, name, converter) != 0) {
167+
if (PyDict_SetItem(state->converters, name, callable) != 0) {
168168
goto error;
169169
}
170170

0 commit comments

Comments
 (0)