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.

Author ers81239
Recipients ers81239
Date 2015-03-17.13:44:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1426599885.89.0.0578302709073.issue23687@psf.upfronthosting.co.za>
In-reply-to
Content
This code:

z = [
        ["Y" for y in None
        ] for x in range(4)
    ]

produces this stacktrace in both Python 2.7 and 3.4:

Traceback (most recent call last):
  File "/Users/edwsmith/dev/untitled4/test.py", line 7, in <module>
    ] for x in range(4)
  File "/Users/edwsmith/dev/untitled4/test.py", line 7, in <listcomp>
    ] for x in range(4)
TypeError: 'NoneType' object is not iterable

Of course my code was slightly more complex, but I lost a fair amount of time troubleshooting how the 'for x in range(4)' was evaluating to None, when really, it was the inner comprehension that was failing.

Ideally the stack trace would say:

Traceback (most recent call last):
  File "/Users/edwsmith/dev/untitled4/test.py", line 6, in <module>
    ["Y" for y in None
  File "/Users/edwsmith/dev/untitled4/test.py", line 6, in <listcomp>
    ["Y" for y in None
TypeError: 'NoneType' object is not iterable
History
Date User Action Args
2015-03-17 13:44:45ers81239setrecipients: + ers81239
2015-03-17 13:44:45ers81239setmessageid: <1426599885.89.0.0578302709073.issue23687@psf.upfronthosting.co.za>
2015-03-17 13:44:45ers81239linkissue23687 messages
2015-03-17 13:44:45ers81239create