Problem with the function splitlines

Bug #1413273 reported by Eugene
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
leo-editor
Invalid
Wishlist
Edward K. Ream

Bug Description

Hello,

I have a problem with string that's contains vertical tab, so function splitlines in the module leoGlobals treats this character as new line and thereby broke the string.

More information described in this issue: http://bugs.python.org/issue22232

As temporary solution I offer to rewrite the function splitlines:

def splitLines (s):

    '''Split s into lines, preserving the number of lines and
    the endings of all lines, including the last line.'''

    # g.stat()

    if s:
        # return s.splitlines(True) # This is a Python string function!
        lines = s.split(os.linesep)
        return [x + os.linesep for x in lines]
    else:
        return []

Revision history for this message
Edward K. Ream (edreamleo) wrote :

This LaunchPad page should not be used for new bug reports.

Please file all new bug reports at: https://github.com/leo-editor/leo-editor/issues

> As temporary solution I offer to rewrite the function g.splitLines:

You are welcome to create your own code, but g.splitLines is not going to change, regardless of problems with str.splitlines.

In particular, making g.splitLines depend on os.linesep would be dangerous: it would infect the code with the so-called "cursed newline problem".

Edward

Changed in leo-editor:
status: New → Invalid
assignee: nobody → Edward K. Ream (edreamleo)
importance: Undecided → Wishlist
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.