Revert "gh-89381: Fix invalid signatures of math/cmath.log (#101404)" by mdickinson · Pull Request #101580 · python/cpython · GitHub
Skip to content
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
2 changes: 1 addition & 1 deletion Doc/library/cmath.rst
9 changes: 5 additions & 4 deletions Doc/library/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,13 @@ Power and logarithmic functions
.. versionadded:: 3.2


.. function:: log(x, base=None)
.. function:: log(x[, base])

Return the logarithm of *x* to the given *base*.
With one argument, return the natural logarithm of *x* (to base *e*).

With two arguments, return the logarithm of *x* to the given *base*,
calculated as ``log(x)/log(base)``.

If the *base* is not specified, returns the natural
logarithm (base *e*) of *x*.

.. function:: log1p(x)

Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,6 @@ def testLog(self):
self.ftest('log(1/e)', math.log(1/math.e), -1)
self.ftest('log(1)', math.log(1), 0)
self.ftest('log(e)', math.log(math.e), 1)
self.ftest('log(e, None)', math.log(math.e, None), 1)
self.ftest('log(32,2)', math.log(32,2), 5)
self.ftest('log(10**40, 10)', math.log(10**40, 10), 40)
self.ftest('log(10**40, 10**20)', math.log(10**40, 10**20), 2)
Expand Down

This file was deleted.

9 changes: 4 additions & 5 deletions Modules/clinic/cmathmodule.c.h

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

44 changes: 25 additions & 19 deletions Modules/clinic/mathmodule.c.h

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

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

z as x: Py_complex
base as y_obj: object = None
base as y_obj: object = NULL
/

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

If the base is not specified or is None, returns the
natural logarithm (base e) of z.
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=e7db51859ebf70bf]*/
/*[clinic end generated code: output=4effdb7d258e0d94 input=230ed3a71ecd000a]*/
{
Py_complex y;

errno = 0;
x = c_log(x);
if (y_obj != Py_None) {
if (y_obj != NULL) {
y = PyComplex_AsCComplex(y_obj);
if (PyErr_Occurred()) {
return NULL;
Expand Down
14 changes: 8 additions & 6 deletions Modules/mathmodule.c