This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2009年12月11日 22:17 by ezio.melotti, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue7482.patch | ezio.melotti, 2009年12月11日 22:17 | Patch against trunk to improve the error messages | ||
| Messages (5) | |||
|---|---|---|---|
| msg96275 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2009年12月11日 22:17 | |
The current error messages for divisions by 0 of float and complex object say "float/complex division", whereas for int and long is "integer/long division by zero": >>> 5/0 ZeroDivisionError: integer division or modulo by zero >>> 5.0/0 ZeroDivisionError: float division The attached patch adds "by zero" to the error messages of float and complex in case of division, modulo or divmod by zero. (Should I add tests to check the error message too?) |
|||
| msg96603 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2009年12月19日 14:03 | |
So if we're going to change the error messages, it would be nice if the new error messages were grammatical English. 'complex division by zero' is fine, but e.g. 'float modulo by zero' doesn't really make sense. Actually I'd be fine with 'float division by zero' for this, since there's an implicit division involved in computing a remainder. Or perhaps something more verbose, like 'right-hand argument to modulo operation is zero'. |
|||
| msg96604 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2009年12月19日 14:08 | |
No, I don't think you should add tests for the error messages; there should already be tests for the type of error, and that's enough. |
|||
| msg96735 - (view) | Author: Boštjan Mejak (Retro) | Date: 2009年12月21日 11:05 | |
The patch is *almost* okay.
errno = 0;
div = c_quot(v->cval,w->cval); /* The raw divisor value. */
if (errno == EDOM) {
- PyErr_SetString(PyExc_ZeroDivisionError, "complex remainder");
+ PyErr_SetString(PyExc_ZeroDivisionError, "complex modulo by zero");
return NULL;
It should be as expressed in the code above. In the patch, the fixed
string is "complex remainder by zero", but this is broken English. I
propose "complex modulo by zero". Please fix your patch and we're good.
|
|||
| msg99778 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2010年02月22日 16:38 | |
Fixed in r78319 (trunk) and r78320 (py3k). I just fixed the 'division' and left the 'modulo' and 'divmod' alone. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:55 | admin | set | github: 51731 |
| 2010年02月22日 16:38:09 | ezio.melotti | set | status: open -> closed versions: - Python 2.6, Python 3.0, Python 3.1 messages: + msg99778 keywords: patch, patch, needs review resolution: fixed stage: patch review -> resolved |
| 2009年12月21日 11:05:01 | Retro | set | nosy:
+ Retro messages: + msg96735 versions: + Python 2.6, Python 3.0, Python 3.1 |
| 2009年12月19日 14:08:52 | mark.dickinson | set | keywords:
patch, patch, needs review messages: + msg96604 |
| 2009年12月19日 14:03:42 | mark.dickinson | set | keywords:
patch, patch, needs review messages: + msg96603 |
| 2009年12月11日 22:17:27 | ezio.melotti | create | |