2to3 chokes on bad character
Frank Millman
frank at chagford.com
Thu Feb 24 08:11:13 EST 2011
"John Machin" <sjmachin at lexicon.net> wrote:
On Feb 23, 7:47 pm, "Frank Millman" <fr... at chagford.com> wrote:
[snip lots of valuable info]
>> The issue is not that 2to3 should handle this correctly, but that it
>> should
>> give a more informative error message to the unsuspecting user.
>Your Python 2.x code should be TESTED before you poke 2to3 at it. In
>this case just trying to run or import the offending code file would
>have given an informative syntax error (you have declared the .py file
>to be encoded in UTF-8 but it's not).
Thank you, John - this is the main lesson.
The file that caused the error has a .py extension, and looks like a python
file, but it just contains documentation. It has never been executed or
imported.
As you say, if I had tried to run it under Python 2 it would have failed
straight away. In these circumstances, it is unreasonable to expect 2to3 to
know what to do with it, so it is definitely not a bug.
>> BTW I have always waited for 'final releases' before upgrading in the
>> past,
>> but this makes me realise the importance of checking out the beta
>> versions -
>> I will do so in future.
>I'm willing to bet that the same would happen with Python 3.1, if a
>3.1 to 3.2 upgrade is what you are talking about
This is my first look at Python 3, so I am talking about moving from 2.6 to
3.2. In this case, it turns out that it was not a bug, but still, in future
I will run some tests when betas are released, just in case I come up with
something.
Thanks for your response - it was very useful.
Frank
More information about the Python-list
mailing list