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 2011年04月28日 01:00 by falsetru, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg134632 - (view) | Author: Jeong-Min Lee (falsetru) | Date: 2011年04月28日 01:00 | |
Expected "TypeError: cannot concatenate 'str' and 'int' objects" exception raised, but got following result. >>> def g(): ... '1' + 0 ... yield 1, 2 ... yield 3, 4 ... >>> zip(*g()) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: zip() argument after * must be a sequence, not generator >>> (lambda xs: 0)(*g()) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: <lambda>() argument after * must be a sequence, not generator >>> list(*g()) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: type object argument after * must be a sequence, not generator >>> list(g()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in g TypeError: cannot concatenate 'str' and 'int' objects |
|||
| msg134636 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2011年04月28日 02:53 | |
It's not just hiding the real error, it's also saying something that isn't true. If you remove the deliberate error from the generator definition, it is clear that generators are perfectly acceptable as *arg inputs: >>> def g(): yield 1, 2 ... >>> list(*g()) [1, 2] |
|||
| msg134665 - (view) | Author: Jeong-Min Lee (falsetru) | Date: 2011年04月28日 09:22 | |
Some exceptions are reported correctly. >>> def g(): ... 1 / 0 ... yield 1, 2 ... yield 3, 4 ... >>> zip(*g()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in g ZeroDivisionError: integer division or modulo by zero >>> def g(): ... [][0] ... yield 1, 2 ... yield 3, 4 ... >>> zip(*g()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in g IndexError: list index out of range |
|||
| msg134712 - (view) | Author: Daniel Urban (daniel.urban) * (Python triager) | Date: 2011年04月28日 18:52 | |
This may be the same/similar as issue4806 (which has a patch). |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:16 | admin | set | github: 56153 |
| 2012年02月04日 02:06:33 | terry.reedy | set | status: open -> closed resolution: duplicate superseder: Function calls taking a generator as star argument can mask TypeErrors in the generator |
| 2012年01月12日 04:41:00 | martin.panter | set | nosy:
+ martin.panter |
| 2011年04月28日 18:52:53 | daniel.urban | set | nosy:
+ daniel.urban messages: + msg134712 |
| 2011年04月28日 09:22:42 | falsetru | set | messages: + msg134665 |
| 2011年04月28日 03:05:28 | eric.araujo | set | nosy:
+ eric.araujo |
| 2011年04月28日 02:53:22 | ncoghlan | set | nosy:
+ ncoghlan messages: + msg134636 |
| 2011年04月28日 01:00:58 | falsetru | set | versions: + Python 3.2, - Python 3.3 |
| 2011年04月28日 01:00:46 | falsetru | create | |