Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
7 changes: 4 additions & 3 deletions 7 Modules/clinic/mathmodule.c.h

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

11 changes: 8 additions & 3 deletions 11 Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2101,8 +2101,8 @@ vector_norm(Py_ssize_t n, double *vec, double max, int found_nan)
/*[clinic input]
math.dist

p: object(subclass_of='&PyTuple_Type')
q: object(subclass_of='&PyTuple_Type')
p: object
q: object
/

Return the Euclidean distance between two points p and q.
Expand All @@ -2116,7 +2116,7 @@ Roughly equivalent to:

static PyObject *
math_dist_impl(PyObject *module, PyObject *p, PyObject *q)
/*[clinic end generated code: output=56bd9538d06bbcfe input=937122eaa5f19272]*/
/*[clinic end generated code: output=56bd9538d06bbcfe input=8c83c07c7a524664]*/
{
PyObject *item;
double max = 0.0;
Expand All @@ -2126,6 +2126,11 @@ math_dist_impl(PyObject *module, PyObject *p, PyObject *q)
double diffs_on_stack[NUM_STACK_ELEMS];
double *diffs = diffs_on_stack;

if (!PyTuple_Check(p) || !PyTuple_Check(q)) {
PyErr_SetString(PyExc_TypeError, "dist argument must be a tuple");
return NULL;
}

m = PyTuple_GET_SIZE(p);
n = PyTuple_GET_SIZE(q);
if (m != n) {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.