diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2019-08-25 02:10:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-25 02:10:39 (GMT) |
commit | aef9ad82f7f667cd001a7112d3bc636e918626f7 (patch) | |
tree | 71bc842de3236a77c6084e951ecf6061693705c0 /Python/clinic | |
parent | 805f8f9afea116c5d4d000570e3d02ae84502f43 (diff) | |
download | cpython-aef9ad82f7f667cd001a7112d3bc636e918626f7.zip cpython-aef9ad82f7f667cd001a7112d3bc636e918626f7.tar.gz cpython-aef9ad82f7f667cd001a7112d3bc636e918626f7.tar.bz2 |
bpo-37942: Improve argument clinic float converter (GH-15470)
Diffstat (limited to 'Python/clinic')
-rw-r--r-- | Python/clinic/sysmodule.c.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Python/clinic/sysmodule.c.h b/Python/clinic/sysmodule.c.h index 1f09e02..2f3bd14 100644 --- a/Python/clinic/sysmodule.c.h +++ b/Python/clinic/sysmodule.c.h @@ -306,9 +306,15 @@ sys_setswitchinterval(PyObject *module, PyObject *arg) PyObject *return_value = NULL; double interval; - interval = PyFloat_AsDouble(arg); - if (PyErr_Occurred()) { - goto exit; + if (PyFloat_CheckExact(arg)) { + interval = PyFloat_AS_DOUBLE(arg); + } + else + { + interval = PyFloat_AsDouble(arg); + if (interval == -1.0 && PyErr_Occurred()) { + goto exit; + } } return_value = sys_setswitchinterval_impl(module, interval); @@ -989,4 +995,4 @@ sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF #define SYS_GETANDROIDAPILEVEL_METHODDEF #endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */ -/*[clinic end generated code: output=acef77d2bb8f6da9 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b26faa0abdd700da input=a9049054013a1b77]*/ |