Skip to content

invalid signature for math.hypot #101123

Closed
@skirpichev

Description

@skirpichev
>>> import math
>>> import inspect
>>> inspect.signature(math.hypot) 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sk/src/cpython/Lib/inspect.py", line 3295, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/src/cpython/Lib/inspect.py", line 3039, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/src/cpython/Lib/inspect.py", line 2531, in _signature_from_callable
    return _signature_from_builtin(sigcls, obj,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/src/cpython/Lib/inspect.py", line 2330, in _signature_from_builtin
    raise ValueError("no signature found for builtin {!r}".format(func))
ValueError: no signature found for builtin <built-in function hypot>

This patch works:

diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 1342162fa7..0e610eb9cb 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -2805,7 +2805,9 @@ math_hypot(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
 #undef NUM_STACK_ELEMS
 
 PyDoc_STRVAR(math_hypot_doc,
-             "hypot(*coordinates) -> value\n\n\
+             "hypot($module, *coordinates)\n\
+--\n\
+\n\
 Multidimensional Euclidean distance from the origin to a point.\n\
 \n\
 Roughly equivalent to:\n\

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions