Re: Python parser problem
Thanks for the reply.
The script was originally edited on Windows with proper \r\n endings, but the
PythonTidy script somehow does the doubling (I guess it assumes UNIX format only), i.e.,
\r\r\n . So indeed, that's kind of messy (and the Python Lang Reference specifies clearly
it interprets \r as a newline, as well) and I didn't realize it with my editor. After
running dos2unix (twice) on the script I cleaned all \r and it went OK.
I guess Python is complaining at line 30 and not at the previous lines, because of
the line-breaking backslash.
On 12/12/2012 9:59 PM, Dave Angel wrote:
> On 12/12/2012 02:10 PM, RCU wrote:
>> I would like to report a parser bug manifesting on Python 2.5, 2.7
>> (but not on 2.2) and 3.3.
>> Please see the attached script.
>> Basically this bug appeared after applying PythonTidy on a valid
>> More exactly, when running:
>> python -c "import iCam_GIT5_5"
>> I get:
>> Traceback (most recent call last):
>> File "<string>", line 1, in<module>
>> File "iCam_GIT5_5.py", line 60
>> SyntaxError: invalid syntax
>> Actually, the error reported by Python is a bug, as far as I see:
>> the line 60 reported in the script does not actually contain the text
>> reported in the error, and this makes quite difficult locating the
>> so-called error.
> No, the error is on line 60. You have blank line between each line, but
> your editor apparently doesn't show you that.
> Your line-endings are messed up. Here's a dump of the first two lines.
> (using hexdump -C)
> 00000000 43 55 52 52 45 4e 54 5f 52 45 4c 45 41 53 45 5f
> 00000010 54 49 4d 45 20 3d 20 27 32 30 31 32 5f 31 32 5f |TIME =
> 00000020 31 30 5f 31 33 5f 30 30 5f 30 30 27 0d 0d 0a 4e
> Notice that the line ends with 0d0d0a, or \r\r\n. That's not valid.
> Apparently python's logic considers that as a line ending with \r,
> followed by a blank line ending with\r\n.
>> In fact the error is at script line 30: we should have all the
>> code on one line, like this
>> playlistToUse = youtubeClient.AddPlaylist(playlistTitle,
>> playlistTitle, playlist_private=False).
>> The "\" used in the script to break the line in 2 is a
>> reminiscence of running PythonTidy-1.22.python (so fixing this bug
>> would be directly relevant when using PythonTidy).
> Nothing wrong with ending with a backslash for continuation. Backslash
> continues the line onto the next one, which is blank. Remove the extra
> \r there and it'll be fine.
>> With this occasion I would like to ask also what are the limits of
>> the Python 2.x and 3.x parser. Where can I find what are the limits on
>> the size/lines of the parsed script?
> Can't help there.
|All times are GMT. The time now is 05:00 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.