Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
gh-89381: Fix signature for math.log and cmath.log
The optional group in math.log seems unnecessary, as far as I can tell.
Once we remove this, Argument Clinic knows what to do.

For cmath, we just do what math is doing, which is use c_default = NULL
(so the actual runtime logic is unchanged), but mark cmath.e as the fake
default value.
  • Loading branch information
hauntsaninja committed Jan 18, 2023
commit c9bb618fe4ea8447173020541f435bf9aabb90f9
6 changes: 3 additions & 3 deletions Modules/clinic/cmathmodule.c.h

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

39 changes: 16 additions & 23 deletions Modules/clinic/mathmodule.c.h

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

6 changes: 3 additions & 3 deletions Modules/cmathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,17 +952,17 @@ cmath_tanh_impl(PyObject *module, Py_complex z)
cmath.log

z as x: Py_complex
base as y_obj: object = NULL
base as y_obj: object(c_default="NULL") = cmath.e
/

log(z[, base]) -> the logarithm of z to the given base.
Return the logarithm of z to the given base.

If the base not specified, returns the natural logarithm (base e) of z.
[clinic start generated code]*/

static PyObject *
cmath_log_impl(PyObject *module, Py_complex x, PyObject *y_obj)
/*[clinic end generated code: output=4effdb7d258e0d94 input=230ed3a71ecd000a]*/
/*[clinic end generated code: output=4effdb7d258e0d94 input=6783d68473d21cf3]*/
{
Py_complex y;

Expand Down
7 changes: 2 additions & 5 deletions Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2366,9 +2366,7 @@ loghelper(PyObject* arg, double (*func)(double))
math.log

x: object
[
base: object(c_default="NULL") = math.e
]
/

Return the logarithm of x to the given base.
Expand All @@ -2377,9 +2375,8 @@ If the base not specified, returns the natural logarithm (base e) of x.
[clinic start generated code]*/

static PyObject *
math_log_impl(PyObject *module, PyObject *x, int group_right_1,
PyObject *base)
/*[clinic end generated code: output=7b5a39e526b73fc9 input=0f62d5726cbfebbd]*/
math_log_impl(PyObject *module, PyObject *x, PyObject *base)
/*[clinic end generated code: output=1dead263cbb1e854 input=59b97db7030bb40b]*/
{
PyObject *num, *den;
PyObject *ans;
Expand Down