-
Notifications
You must be signed in to change notification settings - Fork 102
Closed
Description
Bindings for cursor.execute/executemany can conceptually either be a dictionary (lookup by key) or a sequence (lookup by position).
Currently PyDict_Check is used to determine if it is a dictionary, otherwise PySequence_Fast is used for positional access.
Because PyDict_Check only looks for dict subclasses, it means that UserDict won't work. The apparent solution of PyMapping_Check returns True for UserDict, but also for lists and tuples.
For reference, this is what the builtin _sqlite3 module does
Treat as not a dictionary if:
PyTuple_CheckExact(parameters) || PyList_CheckExact(parameters)
|| (!PyDict_Check(parameters) && PySequence_Check(parameters))
Otherwise treat as dictionary if:
PyDict_Check(parameters)
Otherwise error
Metadata
Metadata
Assignees
Labels
No labels