Issue 2961: Two error messages inconsistent (original) (raw)
Issue2961
Created on 2008-05-25 05:56 by chester, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg67319 - (view) | Author: Chester (chester) | Date: 2008-05-25 05:56 |
Hello, I would like to report that two error messages of the Python parser are not consistent. Please take a look at this: >>> a = "hello" >>> a + 1 Traceback (most recent call last): File "", line 1, in TypeError: cannot concatenate 'str' and 'int' objects >>> 1 + a Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for +: 'int' and 'str' When the order of the objects is changed, that should only change the order of the 'str' and 'int' words in the message. So if a+1, then TypeError: cannot concatenate 'str' and 'int' objects and if 1+a, then TypeError: cannot concatenate 'int' and 'str' objects | ||
msg67321 - (view) | Author: Chester (chester) | Date: 2008-05-25 06:13 |
For the case a + 1 I recommend: TypeError: can't concatenate 'str' and 'int' objects And for the case 1 + a I recommend: TypeError: can't concatenate 'int' and 'str' objects Consistency matters! | ||
msg67327 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2008-05-25 08:03 |
I don't see a problem here. You may be mislead by the assumption that the error messages are generated by the parser, which they aren't -- they are generated at runtime by the objects you try to add. The two types report their failure to do the operation differently -- strings are usually concatenated, so the first one makes sense for strings, but ints have no such notion. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:34 | admin | set | github: 47210 |
2008-05-25 08:03:24 | georg.brandl | set | status: open -> closedresolution: rejectedmessages: + nosy: + georg.brandl |
2008-05-25 06:13:50 | chester | set | messages: + |
2008-05-25 05:56:48 | chester | create |