SourceForge has been redesigned. Learn more.

#36 line function fails for specific data


pyparsing.line has an off by one bug when location is 0 and the text begins with a newline. Instead of returning an empty string, the function returns the entire text, as shown:

Python 2.6.4 (r264:75706, Feb 10 2010, 15:02:54)
[GCC 4.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyparsing
>>> pyparsing.line( 0, '\ntest\n' )

A one character change in pyparsing.line fixes the problem for me. A patch is attached for pyparsing 1.5.2.


  • John Krukoff

    John Krukoff - 2010-03-03

    pyparsing.line patch

  • Paul McGuire

    Paul McGuire - 2010-05-16

    Thanks, John! I just ran this change through my unit tests, and added new tests for this case. This fix will be in 1.5.3, due out very soon now.

  • Paul McGuire

    Paul McGuire - 2010-05-16
    • status: open --> pending-accepted
  • SourceForge Robot

    • status: pending-accepted --> closed-accepted
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).


Log in to post a comment.