Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bpo-37942: Improve argument clinic float converter #15470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions Lib/test/clinic.test
Original file line number Diff line number Diff line change
Expand Up @@ -1587,9 +1587,15 @@ test_float_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (nargs < 1) {
goto skip_optional;
}
a = (float) PyFloat_AsDouble(args[0]);
if (PyErr_Occurred()) {
goto exit;
if (PyFloat_CheckExact(args[0])) {
a = (float) (PyFloat_AS_DOUBLE(args[0]));
}
else
{
a = (float) PyFloat_AsDouble(args[0]);
if (a == -1.0 && PyErr_Occurred()) {
goto exit;
}
}
skip_optional:
return_value = test_float_converter_impl(module, a);
Expand All @@ -1600,7 +1606,7 @@ exit:

static PyObject *
test_float_converter_impl(PyObject *module, float a)
/*[clinic end generated code: output=8293566b2ec1fc52 input=259c0d98eca35034]*/
/*[clinic end generated code: output=6b9c7443d2601cea input=259c0d98eca35034]*/


/*[clinic input]
Expand Down Expand Up @@ -1634,9 +1640,15 @@ test_double_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (nargs < 1) {
goto skip_optional;
}
a = PyFloat_AsDouble(args[0]);
if (PyErr_Occurred()) {
goto exit;
if (PyFloat_CheckExact(args[0])) {
a = PyFloat_AS_DOUBLE(args[0]);
}
else
{
a = PyFloat_AsDouble(args[0]);
if (a == -1.0 && PyErr_Occurred()) {
goto exit;
}
}
skip_optional:
return_value = test_double_converter_impl(module, a);
Expand All @@ -1647,7 +1659,7 @@ exit:

static PyObject *
test_double_converter_impl(PyObject *module, double a)
/*[clinic end generated code: output=487081a9b8da67ab input=c6a9945706a41c27]*/
/*[clinic end generated code: output=5b7b9a0f0791b2cc input=c6a9945706a41c27]*/


/*[clinic input]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve ArgumentClinic converter for floats.
14 changes: 10 additions & 4 deletions Modules/clinic/_ssl.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 28 additions & 10 deletions Modules/clinic/_statisticsmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 46 additions & 16 deletions Modules/clinic/audioop.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 37 additions & 13 deletions Modules/clinic/cmathmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading