On Thu, Nov 5, 2009 at 5:48 PM, Benjamin Peterson <report@bugs.python.org> wrote:

Well, it works for me with the empty newline. Can you isolate the exact problem?

For me, the exact problem seems to be that exec raises a SyntaxError if the code contains a trailing indentation. Here's a summary of everything I've tried:

 * test.py runs successfully on 2.6 and 3.1, regardless of line ending style (LF, CR+LF)

 * "execfile('test.py')" runs successfully on 2.6, regardless of line ending style

 * "exec(compile(open('test.py').read(), 'test.py', 'exec'))" raises a SyntaxError on line 3 of test.py under 2.6 and 3.1, regardless of line ending style.

 * Removing the trailing indentation from test.py causes the above code to succeed under 2.6 and 3.1, regardless of line ending style.

You mentioned that it worked for you with an empty newline. To be clear, the last line of test.py contains a single tab, with no newline character.