summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-12-03 19:52:21 (GMT)
committerGitHub <noreply@github.com>2022-12-03 19:52:21 (GMT)
commita87c46eab3c306b1c5b8a072b7b30ac2c50651c0 (patch)
tree92c0ebdb6abd303ea967c0bd999d839a98f84494 /Modules/_sqlite
parentc68573b339320409b038501fdd7d4f8a56766275 (diff)
downloadcpython-a87c46eab3c306b1c5b8a072b7b30ac2c50651c0.zip
cpython-a87c46eab3c306b1c5b8a072b7b30ac2c50651c0.tar.gz
cpython-a87c46eab3c306b1c5b8a072b7b30ac2c50651c0.tar.bz2
bpo-15999: Accept arbitrary values for boolean parameters. (#15609)
builtins and extension module functions and methods that expect boolean values for parameters now accept any Python object rather than just a bool or int type. This is more consistent with how native Python code itself behaves.
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r--Modules/_sqlite/clinic/connection.c.h14
-rw-r--r--Modules/_sqlite/connection.c12
2 files changed, 13 insertions, 13 deletions
diff --git a/Modules/_sqlite/clinic/connection.c.h b/Modules/_sqlite/clinic/connection.c.h
index 1f9841c..4c3fd1b 100644
--- a/Modules/_sqlite/clinic/connection.c.h
+++ b/Modules/_sqlite/clinic/connection.c.h
@@ -100,8 +100,8 @@ pysqlite_connection_init(PyObject *self, PyObject *args, PyObject *kwargs)
}
}
if (fastargs[4]) {
- check_same_thread = _PyLong_AsInt(fastargs[4]);
- if (check_same_thread == -1 && PyErr_Occurred()) {
+ check_same_thread = PyObject_IsTrue(fastargs[4]);
+ if (check_same_thread < 0) {
goto exit;
}
if (!--noptargs) {
@@ -305,8 +305,8 @@ blobopen(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyO
goto skip_optional_kwonly;
}
if (args[3]) {
- readonly = _PyLong_AsInt(args[3]);
- if (readonly == -1 && PyErr_Occurred()) {
+ readonly = PyObject_IsTrue(args[3]);
+ if (readonly < 0) {
goto exit;
}
if (!--noptargs) {
@@ -831,8 +831,8 @@ pysqlite_connection_enable_load_extension(pysqlite_Connection *self, PyObject *a
PyObject *return_value = NULL;
int onoff;
- onoff = _PyLong_AsInt(arg);
- if (onoff == -1 && PyErr_Occurred()) {
+ onoff = PyObject_IsTrue(arg);
+ if (onoff < 0) {
goto exit;
}
return_value = pysqlite_connection_enable_load_extension_impl(self, onoff);
@@ -1532,4 +1532,4 @@ exit:
#ifndef DESERIALIZE_METHODDEF
#define DESERIALIZE_METHODDEF
#endif /* !defined(DESERIALIZE_METHODDEF) */
-/*[clinic end generated code: output=20e929a7a7d62a01 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f10306e10427488b input=a9049054013a1b77]*/
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 2854c1b..4c07d5e 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -197,7 +197,7 @@ _sqlite3.Connection.__init__ as pysqlite_connection_init
timeout: double = 5.0
detect_types: int = 0
isolation_level: IsolationLevel = ""
- check_same_thread: bool(accept={int}) = True
+ check_same_thread: bool = True
factory: object(c_default='(PyObject*)clinic_state()->ConnectionType') = ConnectionType
cached_statements as cache_size: int = 128
uri: bool = False
@@ -212,7 +212,7 @@ pysqlite_connection_init_impl(pysqlite_Connection *self, PyObject *database,
int check_same_thread, PyObject *factory,
int cache_size, int uri,
enum autocommit_mode autocommit)
-/*[clinic end generated code: output=cba057313ea7712f input=b21abce28ebcd304]*/
+/*[clinic end generated code: output=cba057313ea7712f input=9b0ab6c12f674fa3]*/
{
if (PySys_Audit("sqlite3.connect", "O", database) < 0) {
return -1;
@@ -485,7 +485,7 @@ _sqlite3.Connection.blobopen as blobopen
Row index.
/
*
- readonly: bool(accept={int}) = False
+ readonly: bool = False
Open the BLOB without write permissions.
name: str = "main"
Database name.
@@ -496,7 +496,7 @@ Open and return a BLOB object.
static PyObject *
blobopen_impl(pysqlite_Connection *self, const char *table, const char *col,
int row, int readonly, const char *name)
-/*[clinic end generated code: output=0c8e2e58516d0b5c input=1e7052516acfc94d]*/
+/*[clinic end generated code: output=0c8e2e58516d0b5c input=fa73c83aa7a7ddee]*/
{
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
return NULL;
@@ -1564,7 +1564,7 @@ pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
/*[clinic input]
_sqlite3.Connection.enable_load_extension as pysqlite_connection_enable_load_extension
- enable as onoff: bool(accept={int})
+ enable as onoff: bool
/
Enable dynamic loading of SQLite extension modules.
@@ -1573,7 +1573,7 @@ Enable dynamic loading of SQLite extension modules.
static PyObject *
pysqlite_connection_enable_load_extension_impl(pysqlite_Connection *self,
int onoff)
-/*[clinic end generated code: output=9cac37190d388baf input=5f00e93f7a9d3540]*/
+/*[clinic end generated code: output=9cac37190d388baf input=2a1e87931486380f]*/
{
int rc;