compile() error

Jerry Hill malaclypse2 at gmail.com
Wed May 19 21:12:24 EDT 2010


On Wed, May 19, 2010 at 8:52 PM, Steven D'Aprano
<steve-REMOVE-THIS at cybersource.com.au> wrote:
> On Wed, 19 May 2010 22:31:31 +0000, Benjamin Peterson wrote:
>> Iuri <iurisilvio <at> gmail.com> writes:
>>> Any ideas about what is happening?
>>
>> Until Python 2.7/3.2, compile() does't like sources which don't end in a
>> newline.

It appears to be this bug: http://bugs.python.org/issue1184112 which
is still open.  Maybe a fix got checked in without the bug being
closed?  I don't have 2.7 or 3.2 here to test with.

> The original post isn't showing up for me, so I don't know the full
> context, but it seems to me that compile can deal with the lack of
> newline.

The original example was:
compile("for i in [1,2,3]:\n pass\n#end", "test_file.py", "exec")

Bug 1184112 is only triggered with an indented block followed by a
comment with no newline following the comment.

-- 
Jerry



More information about the Python-list mailing list