summaryrefslogtreecommitdiffstats
path: root/Modules/clinic
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2023-01-29 19:50:10 (GMT)
committerGitHub <noreply@github.com>2023-01-29 19:50:10 (GMT)
commit0ef92d979311ba82d4c41b22ef38e12e1b08b13d (patch)
treeebaf07f12852edaf9f858e41c5e15b1df37f4034 /Modules/clinic
parent666c0840dcac9941fa41ec619fef8d45cd849a0b (diff)
downloadcpython-0ef92d979311ba82d4c41b22ef38e12e1b08b13d.zip
cpython-0ef92d979311ba82d4c41b22ef38e12e1b08b13d.tar.gz
cpython-0ef92d979311ba82d4c41b22ef38e12e1b08b13d.tar.bz2
gh-89381: Fix invalid signatures of math/cmath.log (#101404)
Diffstat (limited to 'Modules/clinic')
-rw-r--r--Modules/clinic/cmathmodule.c.h9
-rw-r--r--Modules/clinic/mathmodule.c.h44
2 files changed, 24 insertions, 29 deletions
diff --git a/Modules/clinic/cmathmodule.c.h b/Modules/clinic/cmathmodule.c.h
index b1da945..bc91c20 100644
--- a/Modules/clinic/cmathmodule.c.h
+++ b/Modules/clinic/cmathmodule.c.h
@@ -639,12 +639,13 @@ exit:
}
PyDoc_STRVAR(cmath_log__doc__,
-"log($module, z, base=<unrepresentable>, /)\n"
+"log($module, z, base=None, /)\n"
"--\n"
"\n"
"log(z[, base]) -> the logarithm of z to the given base.\n"
"\n"
-"If the base not specified, returns the natural logarithm (base e) of z.");
+"If the base is not specified or is None, returns the\n"
+"natural logarithm (base e) of z.");
#define CMATH_LOG_METHODDEF \
{"log", _PyCFunction_CAST(cmath_log), METH_FASTCALL, cmath_log__doc__},
@@ -657,7 +658,7 @@ cmath_log(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
Py_complex x;
- PyObject *y_obj = NULL;
+ PyObject *y_obj = Py_None;
if (!_PyArg_CheckPositional("log", nargs, 1, 2)) {
goto exit;
@@ -982,4 +983,4 @@ skip_optional_kwonly:
exit:
return return_value;
}
-/*[clinic end generated code: output=0146c656e67f5d5f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=2630f8740909a8f7 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/mathmodule.c.h b/Modules/clinic/mathmodule.c.h
index 1f97258..0d61fd1 100644
--- a/Modules/clinic/mathmodule.c.h
+++ b/Modules/clinic/mathmodule.c.h
@@ -187,43 +187,37 @@ exit:
}
PyDoc_STRVAR(math_log__doc__,
-"log(x, [base=math.e])\n"
+"log($module, x, base=None, /)\n"
+"--\n"
+"\n"
"Return the logarithm of x to the given base.\n"
"\n"
-"If the base not specified, returns the natural logarithm (base e) of x.");
+"If the base is not specified or is None, returns the natural\n"
+"logarithm (base e) of x.");
#define MATH_LOG_METHODDEF \
- {"log", (PyCFunction)math_log, METH_VARARGS, math_log__doc__},
+ {"log", _PyCFunction_CAST(math_log), METH_FASTCALL, math_log__doc__},
static PyObject *
-math_log_impl(PyObject *module, PyObject *x, int group_right_1,
- PyObject *base);
+math_log_impl(PyObject *module, PyObject *x, PyObject *base);
static PyObject *
-math_log(PyObject *module, PyObject *args)
+math_log(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *x;
- int group_right_1 = 0;
- PyObject *base = NULL;
+ PyObject *base = Py_None;
- switch (PyTuple_GET_SIZE(args)) {
- case 1:
- if (!PyArg_ParseTuple(args, "O:log", &x)) {
- goto exit;
- }
- break;
- case 2:
- if (!PyArg_ParseTuple(args, "OO:log", &x, &base)) {
- goto exit;
- }
- group_right_1 = 1;
- break;
- default:
- PyErr_SetString(PyExc_TypeError, "math.log requires 1 to 2 arguments");
- goto exit;
+ if (!_PyArg_CheckPositional("log", nargs, 1, 2)) {
+ goto exit;
+ }
+ x = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
}
- return_value = math_log_impl(module, x, group_right_1, base);
+ base = args[1];
+skip_optional:
+ return_value = math_log_impl(module, x, base);
exit:
return return_value;
@@ -954,4 +948,4 @@ math_ulp(PyObject *module, PyObject *arg)
exit:
return return_value;
}
-/*[clinic end generated code: output=899211ec70e4506c input=a9049054013a1b77]*/
+/*[clinic end generated code: output=afec63ebb0da709a input=a9049054013a1b77]*/