diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-12-03 19:52:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-03 19:52:21 (GMT) |
commit | a87c46eab3c306b1c5b8a072b7b30ac2c50651c0 (patch) | |
tree | 92c0ebdb6abd303ea967c0bd999d839a98f84494 /Python | |
parent | c68573b339320409b038501fdd7d4f8a56766275 (diff) | |
download | cpython-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 'Python')
-rw-r--r-- | Python/bltinmodule.c | 4 | ||||
-rw-r--r-- | Python/clinic/bltinmodule.c.h | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index b3b7e8d..ff96c25 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -714,7 +714,7 @@ compile as builtin_compile filename: object(converter="PyUnicode_FSDecoder") mode: str flags: int = 0 - dont_inherit: bool(accept={int}) = False + dont_inherit: bool = False optimize: int = -1 * _feature_version as feature_version: int = -1 @@ -737,7 +737,7 @@ static PyObject * builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename, const char *mode, int flags, int dont_inherit, int optimize, int feature_version) -/*[clinic end generated code: output=b0c09c84f116d3d7 input=40171fb92c1d580d]*/ +/*[clinic end generated code: output=b0c09c84f116d3d7 input=cc78e20e7c7682ba]*/ { PyObject *source_copy; const char *str; diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h index 19930a5..89f069d 100644 --- a/Python/clinic/bltinmodule.c.h +++ b/Python/clinic/bltinmodule.c.h @@ -354,8 +354,8 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj } } if (args[4]) { - dont_inherit = _PyLong_AsInt(args[4]); - if (dont_inherit == -1 && PyErr_Occurred()) { + dont_inherit = PyObject_IsTrue(args[4]); + if (dont_inherit < 0) { goto exit; } if (!--noptargs) { @@ -1215,4 +1215,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=3c9497e0ffeb8a30 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=973da43fa65aa727 input=a9049054013a1b77]*/ |