summaryrefslogtreecommitdiffstats
path: root/Objects/clinic
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 /Objects/clinic
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 'Objects/clinic')
-rw-r--r--Objects/clinic/bytearrayobject.c.h6
-rw-r--r--Objects/clinic/bytesobject.c.h6
-rw-r--r--Objects/clinic/listobject.c.h6
-rw-r--r--Objects/clinic/unicodeobject.c.h6
4 files changed, 12 insertions, 12 deletions
diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h
index 142f299..e7bf318 100644
--- a/Objects/clinic/bytearrayobject.c.h
+++ b/Objects/clinic/bytearrayobject.c.h
@@ -1084,8 +1084,8 @@ bytearray_splitlines(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t
if (!noptargs) {
goto skip_optional_pos;
}
- keepends = _PyLong_AsInt(args[0]);
- if (keepends == -1 && PyErr_Occurred()) {
+ keepends = PyObject_IsTrue(args[0]);
+ if (keepends < 0) {
goto exit;
}
skip_optional_pos:
@@ -1287,4 +1287,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{
return bytearray_sizeof_impl(self);
}
-/*[clinic end generated code: output=72bfa6cac2fd6832 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=022698e8b0faa272 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h
index 904124e..060056d 100644
--- a/Objects/clinic/bytesobject.c.h
+++ b/Objects/clinic/bytesobject.c.h
@@ -839,8 +839,8 @@ bytes_splitlines(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, P
if (!noptargs) {
goto skip_optional_pos;
}
- keepends = _PyLong_AsInt(args[0]);
- if (keepends == -1 && PyErr_Occurred()) {
+ keepends = PyObject_IsTrue(args[0]);
+ if (keepends < 0) {
goto exit;
}
skip_optional_pos:
@@ -1063,4 +1063,4 @@ skip_optional_pos:
exit:
return return_value;
}
-/*[clinic end generated code: output=5e0a25b7ba749a04 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=31a9e4af85562612 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/listobject.c.h b/Objects/clinic/listobject.c.h
index 926eaa5..94852e9 100644
--- a/Objects/clinic/listobject.c.h
+++ b/Objects/clinic/listobject.c.h
@@ -215,8 +215,8 @@ list_sort(PyListObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject
goto skip_optional_kwonly;
}
}
- reverse = _PyLong_AsInt(args[1]);
- if (reverse == -1 && PyErr_Occurred()) {
+ reverse = PyObject_IsTrue(args[1]);
+ if (reverse < 0) {
goto exit;
}
skip_optional_kwonly:
@@ -382,4 +382,4 @@ list___reversed__(PyListObject *self, PyObject *Py_UNUSED(ignored))
{
return list___reversed___impl(self);
}
-/*[clinic end generated code: output=782ed6c68b1c9f83 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=4e6f38b655394564 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h
index d803a27..f640c99 100644
--- a/Objects/clinic/unicodeobject.c.h
+++ b/Objects/clinic/unicodeobject.c.h
@@ -1193,8 +1193,8 @@ unicode_splitlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb
if (!noptargs) {
goto skip_optional_pos;
}
- keepends = _PyLong_AsInt(args[0]);
- if (keepends == -1 && PyErr_Occurred()) {
+ keepends = PyObject_IsTrue(args[0]);
+ if (keepends < 0) {
goto exit;
}
skip_optional_pos:
@@ -1497,4 +1497,4 @@ skip_optional_pos:
exit:
return return_value;
}
-/*[clinic end generated code: output=e775ff4154f1c935 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=05d942840635dadf input=a9049054013a1b77]*/