[issue7268] 2to3 execfile conversion changes behavior

2010-07-09 Thread Benjamin Peterson
Benjamin Peterson added the comment: Closing since compile() will work properly now. -- resolution: -> works for me status: open -> closed ___ Python tracker ___ ___

[issue7268] 2to3 execfile conversion changes behavior

2010-07-09 Thread Éric Araujo
Éric Araujo added the comment: Not sure if this merits a new bug report: The conversion currently promotes the open().read() anti-pattern, which is not guaranteed to release file handles as soon as possible in all VMs. Using a with block would fix that. -- nosy: +merwok _

[issue7268] 2to3 execfile conversion changes behavior

2010-07-09 Thread Éric Araujo
Changes by Éric Araujo : Removed file: http://bugs.python.org/file15273/unnamed ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubs

[issue7268] 2to3 execfile conversion changes behavior

2009-11-16 Thread Benjamin Peterson
Benjamin Peterson added the comment: I've fixed underlying compile() newline problem in the trunk and py3k. However, I think that change is big enough that I don't want to to backport it. I'm leaving this open to think about what to do with 2to3 in this situation. -- priority: -> norma

[issue7268] 2to3 execfile conversion changes behavior

2009-11-07 Thread Gabriel Genellina
Gabriel Genellina added the comment: This is a patch for the execfile fixer, so it converts execfile("fn") into this: exec(compile(open("fn").read()+'\n', "fn", 'exec')) (Yes, it looks ugly. A better way would be to fix the compile() builtin so it does not require the last line

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk
flashk added the comment: I noticed that calling "exec('\t')" raises a SyntaxError, so maybe this is the root of the problem. I manually added a newline character to the end of the file contents and it fixes the issue for me: exec(compile(open('test.py').read()+'\n', 'test.py', 'exec')) So m

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk
flashk added the comment: On Thu, Nov 5, 2009 at 5:48 PM, Benjamin Peterson 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

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread Benjamin Peterson
Benjamin Peterson added the comment: 2009/11/5 flashk : > > flashk added the comment: > > Ok, but why am I still getting a syntax error in both 2.6 and 3.1 on the > file, even after converting the newlines? > > If I remove the trailing indentation then everything works properly on 2.6 > and 3.1

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk
flashk added the comment: Ok, but why am I still getting a syntax error in both 2.6 and 3.1 on the file, even after converting the newlines? If I remove the trailing indentation then everything works properly on 2.6 and 3.1, even with DOS newlines. It just seems that exec does not properly h

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread Benjamin Peterson
Benjamin Peterson added the comment: 2009/11/5 flashk : > > flashk added the comment: > > Ok, I converted test.py to use Unix style newlines and still get the > syntax error on both 2.6 and 3.1. I'm confused as to why execfile works on > the file but reading the contents and passing it to exec

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk
flashk added the comment: Ok, I converted test.py to use Unix style newlines and still get the syntax error on both 2.6 and 3.1. I'm confused as to why execfile works on the file but reading the contents and passing it to exec behaves differently under 2.6. Sorry if I'm just being dense. ---

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread Benjamin Peterson
Benjamin Peterson added the comment: This is because you have DOS newlines which the Python compiler cannot handle. In 2.x, open("test.py", "r") does not translate newlines. In 3.x, it does. -- ___ Python tracker _

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk
flashk added the comment: I'm running this code under 2.6, so the print statement should not be the issue. I've attached a new version of test.py that simply performs a variable assignment and I still get the syntax error on both 2.6 and 3.1 with the exec function. Also, the syntax error is r

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread Benjamin Peterson
Benjamin Peterson added the comment: test.py is invalid Python 3 syntax. -- resolution: -> invalid status: open -> closed ___ Python tracker ___

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk
flashk added the comment: I just attached the files individually. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscr

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk
Changes by flashk : Added file: http://bugs.python.org/file15270/execfile_example_converted.py ___ Python tracker ___ ___ Python-bugs-list mail

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk
Changes by flashk : Added file: http://bugs.python.org/file15269/execfile_example.py ___ Python tracker ___ ___ Python-bugs-list mailing list U

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk
Changes by flashk : Added file: http://bugs.python.org/file15268/test.py ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread Benjamin Peterson
Benjamin Peterson added the comment: Could you attach the files separately or paste them into the bug? zip files are hard to work with. -- nosy: +benjamin.peterson ___ Python tracker ___

[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk
New submission from flashk : I recently ran 2to3 on some of my scripts and noticed a change in behavior. I had a script that used the built-in execfile function. After the conversion, it was changed to manually open the file and read the contents into the exec function. Now I am getting a Sy