Skip to content

Commit 0672a6c

Browse files
authored
Revert "gh-89381: Fix invalid signatures of math/cmath.log (#101404)" (#101580)
This reverts commit 0ef92d9.
1 parent 19ac436 commit 0672a6c

File tree

8 files changed

+47
-42
lines changed

8 files changed

+47
-42
lines changed

Doc/library/cmath.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Power and logarithmic functions
8989
logarithms.
9090

9191

92-
.. function:: log(x, base=None)
92+
.. function:: log(x[, base])
9393

9494
Returns the logarithm of *x* to the given *base*. If the *base* is not
9595
specified, returns the natural logarithm of *x*. There is one branch cut, from 0

Doc/library/math.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,13 @@ Power and logarithmic functions
393393
.. versionadded:: 3.2
394394

395395

396-
.. function:: log(x, base=None)
396+
.. function:: log(x[, base])
397397

398-
Return the logarithm of *x* to the given *base*.
398+
With one argument, return the natural logarithm of *x* (to base *e*).
399+
400+
With two arguments, return the logarithm of *x* to the given *base*,
401+
calculated as ``log(x)/log(base)``.
399402

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

403404
.. function:: log1p(x)
404405

Lib/test/test_math.py

-1
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,6 @@ def testLog(self):
11461146
self.ftest('log(1/e)', math.log(1/math.e), -1)
11471147
self.ftest('log(1)', math.log(1), 0)
11481148
self.ftest('log(e)', math.log(math.e), 1)
1149-
self.ftest('log(e, None)', math.log(math.e, None), 1)
11501149
self.ftest('log(32,2)', math.log(32,2), 5)
11511150
self.ftest('log(10**40, 10)', math.log(10**40, 10), 40)
11521151
self.ftest('log(10**40, 10**20)', math.log(10**40, 10**20), 2)

Misc/NEWS.d/next/Library/2023-01-16-10-42-58.gh-issue-89381.lM2WL0.rst

-1
This file was deleted.

Modules/clinic/cmathmodule.c.h

+4-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/mathmodule.c.h

+25-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/cmathmodule.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -952,24 +952,23 @@ cmath_tanh_impl(PyObject *module, Py_complex z)
952952
cmath.log
953953
954954
z as x: Py_complex
955-
base as y_obj: object = None
955+
base as y_obj: object = NULL
956956
/
957957
958958
log(z[, base]) -> the logarithm of z to the given base.
959959
960-
If the base is not specified or is None, returns the
961-
natural logarithm (base e) of z.
960+
If the base not specified, returns the natural logarithm (base e) of z.
962961
[clinic start generated code]*/
963962

964963
static PyObject *
965964
cmath_log_impl(PyObject *module, Py_complex x, PyObject *y_obj)
966-
/*[clinic end generated code: output=4effdb7d258e0d94 input=e7db51859ebf70bf]*/
965+
/*[clinic end generated code: output=4effdb7d258e0d94 input=230ed3a71ecd000a]*/
967966
{
968967
Py_complex y;
969968

970969
errno = 0;
971970
x = c_log(x);
972-
if (y_obj != Py_None) {
971+
if (y_obj != NULL) {
973972
y = PyComplex_AsCComplex(y_obj);
974973
if (PyErr_Occurred()) {
975974
return NULL;

Modules/mathmodule.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -2366,24 +2366,26 @@ loghelper(PyObject* arg, double (*func)(double))
23662366
math.log
23672367
23682368
x: object
2369-
base: object = None
2369+
[
2370+
base: object(c_default="NULL") = math.e
2371+
]
23702372
/
23712373
23722374
Return the logarithm of x to the given base.
23732375
2374-
If the base is not specified or is None, returns the natural
2375-
logarithm (base e) of x.
2376+
If the base not specified, returns the natural logarithm (base e) of x.
23762377
[clinic start generated code]*/
23772378

23782379
static PyObject *
2379-
math_log_impl(PyObject *module, PyObject *x, PyObject *base)
2380-
/*[clinic end generated code: output=1dead263cbb1e854 input=ef032cc9837943e1]*/
2380+
math_log_impl(PyObject *module, PyObject *x, int group_right_1,
2381+
PyObject *base)
2382+
/*[clinic end generated code: output=7b5a39e526b73fc9 input=0f62d5726cbfebbd]*/
23812383
{
23822384
PyObject *num, *den;
23832385
PyObject *ans;
23842386

23852387
num = loghelper(x, m_log);
2386-
if (num == NULL || base == Py_None)
2388+
if (num == NULL || base == NULL)
23872389
return num;
23882390

23892391
den = loghelper(base, m_log);

0 commit comments

Comments
 (0)