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 2014年09月10日 02:54 by fossilet, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| str_join_exception_message.diff | fossilet, 2014年09月10日 02:54 | patch | review | |
| str_join_exception_message_1.diff | fossilet, 2014年09月12日 06:58 | new patch that checks exception message | review | |
| test_for_35.diff | fossilet, 2014年09月12日 07:01 | add test for 3.5 | review | |
| test_for_35-1.diff | fossilet, 2014年09月15日 08:33 | review | ||
| Messages (11) | |||
|---|---|---|---|
| msg226675 - (view) | Author: Yongzhi Pan (fossilet) * | Date: 2014年09月10日 02:54 | |
In the 2.7 branch, the exception message of str.join is missing when the argument is non-sequence: >>> ' '.join(None) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError I fix this with a patch. After this: >>> ' '.join(None) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: can only join an iterable I also add test to this case. Can the test also be added to 3.x branches? |
|||
| msg226695 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2014年09月10日 12:55 | |
Thanks for the report and patch. The test doesn't fail before your patch. I think checkraises should be changed to make sure the message isn't empty. And yes, the tests should be added to 3.5. |
|||
| msg226808 - (view) | Author: Yongzhi Pan (fossilet) * | Date: 2014年09月12日 07:01 | |
I updated the patches. Since exceptions in 3 do not have a message attribute, I did not check them. Are they OK? |
|||
| msg226818 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2014年09月12日 13:33 | |
You can check .args[0] in python3. Can you include a complete patch for python3? Your test_for_35 only has a change for test_bytes, not the ones for string_tests. |
|||
| msg226830 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年09月12日 17:58 | |
> You can check .args[0] in python3. Or str(cm.exception). This works on 2.7 too. |
|||
| msg226904 - (view) | Author: Yongzhi Pan (fossilet) * | Date: 2014年09月15日 08:33 | |
I have updated the test for 3.5. The related tests pass after the patching. Are they OK now? There are two caveats: I did not update test_bytes in 2.7, and I did not add checkraises in test_bytes in 3.5. |
|||
| msg226923 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2014年09月15日 15:41 | |
The str of the exception will always be nonblank (it will contain the string 'TypeError' at a minimum). So you need to peel off the 'TypeError:' prefix before testing if you want to use str(e). That's why I suggested using args[0], but I suppose that might be a little more fragile. |
|||
| msg226943 - (view) | Author: Yongzhi Pan (fossilet) * | Date: 2014年09月16日 08:34 | |
I tested it and find str of an exception does not contain the exception type:
>>> a = TypeError()
>>> str(a)
''
>>> a = TypeError('b', 3)
>>> a.args
('b', 3)
>>> str(a)
"('b', 3)"
Am I missing some other circumstances?
|
|||
| msg226962 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2014年09月16日 17:47 | |
No, you are right and I am wrong. I should have checked myself :) |
|||
| msg227750 - (view) | Author: Yongzhi Pan (fossilet) * | Date: 2014年09月28日 03:13 | |
Do the patches still have problems? |
|||
| msg227768 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2014年09月28日 16:57 | |
New changeset 0ad19246d16d by Benjamin Peterson in branch '2.7': give exception a nice message (closes #22379) https://hg.python.org/cpython/rev/0ad19246d16d New changeset ab1570d0132d by Benjamin Peterson in branch '3.4': check that exception messages are not empty (#22379) https://hg.python.org/cpython/rev/ab1570d0132d New changeset 78727a11b5ae by Benjamin Peterson in branch 'default': merge 3.4 (#22379) https://hg.python.org/cpython/rev/78727a11b5ae |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:07 | admin | set | github: 66573 |
| 2014年09月28日 16:57:31 | python-dev | set | status: open -> closed nosy: + python-dev messages: + msg227768 resolution: fixed stage: needs patch -> resolved |
| 2014年09月28日 03:13:36 | fossilet | set | messages: + msg227750 |
| 2014年09月16日 17:47:47 | r.david.murray | set | messages: + msg226962 |
| 2014年09月16日 08:34:46 | fossilet | set | messages: + msg226943 |
| 2014年09月15日 15:41:08 | r.david.murray | set | messages: + msg226923 |
| 2014年09月15日 08:33:49 | fossilet | set | files:
+ test_for_35-1.diff messages: + msg226904 |
| 2014年09月12日 17:58:50 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg226830 |
| 2014年09月12日 13:33:53 | r.david.murray | set | messages: + msg226818 |
| 2014年09月12日 07:01:26 | fossilet | set | files:
+ test_for_35.diff messages: + msg226808 |
| 2014年09月12日 06:58:33 | fossilet | set | files:
+ str_join_exception_message_1.diff versions: + Python 3.5 |
| 2014年09月11日 08:02:57 | serhiy.storchaka | set | nosy:
+ pitrou |
| 2014年09月10日 12:55:55 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg226695 components: + Interpreter Core, - ctypes type: enhancement -> behavior stage: needs patch |
| 2014年09月10日 02:54:51 | fossilet | create | |