Skip to content

Commit bce3e17

Browse files
committed
#7482: clarify error message in case of division by zero of float and complex numbers.
1 parent 38c1236 commit bce3e17

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎Objects/complexobject.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ complex_div(PyObject *v, PyObject *w)
563563
quot = c_quot(a, b);
564564
PyFPE_END_PROTECT(quot)
565565
if (errno == EDOM) {
566-
PyErr_SetString(PyExc_ZeroDivisionError, "complex division");
566+
PyErr_SetString(PyExc_ZeroDivisionError, "complex division by zero");
567567
return NULL;
568568
}
569569
return PyComplex_FromCComplex(quot);
@@ -586,7 +586,7 @@ complex_classic_div(PyObject *v, PyObject *w)
586586
quot = c_quot(a, b);
587587
PyFPE_END_PROTECT(quot)
588588
if (errno == EDOM) {
589-
PyErr_SetString(PyExc_ZeroDivisionError, "complex division");
589+
PyErr_SetString(PyExc_ZeroDivisionError, "complex division by zero");
590590
return NULL;
591591
}
592592
return PyComplex_FromCComplex(quot);

‎Objects/floatobject.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ float_div(PyObject *v, PyObject *w)
668668
#ifdef Py_NAN
669669
if (b == 0.0) {
670670
PyErr_SetString(PyExc_ZeroDivisionError,
671-
"float division");
671+
"float division by zero");
672672
return NULL;
673673
}
674674
#endif
@@ -690,7 +690,7 @@ float_classic_div(PyObject *v, PyObject *w)
690690
#ifdef Py_NAN
691691
if (b == 0.0) {
692692
PyErr_SetString(PyExc_ZeroDivisionError,
693-
"float division");
693+
"float division by zero");
694694
return NULL;
695695
}
696696
#endif

0 commit comments

Comments
 (0)