Re: Python parser problem

Discussion in 'Python' started by Dave Angel, Dec 12, 2012.

  1. Dave Angel

    Dave Angel Guest

    On 12/12/2012 02:10 PM, RCU wrote:
    > Hello.
    > 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
    > script.
    >
    > 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
    |CURRENT_RELEASE_|
    00000010 54 49 4d 45 20 3d 20 27 32 30 31 32 5f 31 32 5f |TIME =
    '2012_12_|
    00000020 31 30 5f 31 33 5f 30 30 5f 30 30 27 0d 0d 0a 4e
    |10_13_00_00'...N|

    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.




    --

    DaveA
    Dave Angel, Dec 12, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bernd Oninger
    Replies:
    0
    Views:
    739
    Bernd Oninger
    Jun 9, 2004
  2. ZOCOR

    XML Parser VS HTML Parser

    ZOCOR, Oct 3, 2004, in forum: Java
    Replies:
    11
    Views:
    793
    Paul King
    Oct 5, 2004
  3. Bernd Oninger
    Replies:
    0
    Views:
    794
    Bernd Oninger
    Jun 9, 2004
  4. Joel Hedlund
    Replies:
    2
    Views:
    483
    Joel Hedlund
    Nov 11, 2006
  5. Joel Hedlund
    Replies:
    0
    Views:
    290
    Joel Hedlund
    Nov 11, 2006
Loading...

Share This Page