flashk <fla...@gmail.com> added the comment:

On Thu, Nov 5, 2009 at 5:48 PM, Benjamin Peterson <rep...@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.

----------
Added file: http://bugs.python.org/file15273/unnamed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7268>
_______________________________________
<div class="gmail_quote">On Thu, Nov 5, 2009 at 5:48 PM, Benjamin Peterson 
<span dir="ltr">&lt;<a 
href="mailto:rep...@bugs.python.org";>rep...@bugs.python.org</a>&gt;</span> 
wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px 
#ccc solid;padding-left:1ex;">

<div class="im">
<br>
</div>Well, it works for me with the empty newline. Can you isolate the exact 
problem?</blockquote><div><br></div><div>For me, the exact problem seems to be 
that exec raises a SyntaxError if the code contains a trailing indentation. 
Here&#39;s a summary of everything I&#39;ve tried:</div>

<div><br></div><div> * test.py runs successfully on 2.6 and 3.1, regardless of 
line ending style (LF, CR+LF)</div><div><br></div><div> * 
&quot;execfile(&#39;test.py&#39;)&quot; runs successfully on 2.6, regardless of 
line ending style</div>

<div><br></div><div> * &quot;exec(compile(open(&#39;test.py&#39;).read(), 
&#39;test.py&#39;, &#39;exec&#39;))&quot; raises a SyntaxError on line 3 of 
test.py under 2.6 and 3.1, regardless of line ending style.</div><div>
<br>
</div><div> * Removing the trailing indentation from test.py causes the above 
code to succeed under 2.6 and 3.1, regardless of line ending 
style.</div><div><br></div><div>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.</div>

<div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to