[LyX/master] lyx2lyx: Fix trim_eol_binary() to strip \r on CRLF files

Udi Fogiel <[email protected]> Tue, 04 Aug 2026 16:43:16 +0000
Newsgroups gmane.editors.lyx.cvs
Message-ID <[email protected]>
commit e4245896595c733e5e85984b41ea21e158c5a52c
Author: Udi Fogiel <[email protected]>
Date:   Tue Aug 4 19:23:54 2026 +0300

    lyx2lyx: Fix trim_eol_binary() to strip \r on CRLF files
    
    line[-2:-1] == 13 compares a bytes slice to an int,
    which is always False in Python 3
---
 lib/lyx2lyx/LyX.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py
index ab3e915859..ce27d27f95 100644
--- a/lib/lyx2lyx/LyX.py
+++ b/lib/lyx2lyx/LyX.py
@@ -191,7 +191,7 @@ def trim_eol_binary(line):
     if line[-1] != 10 and line[-1] != 13:
         # May happen for the last line of a document
         return line
-    if line[-2:-1] == 13:
+    if len(line) >= 2 and line[-2] == 13:
         return line[:-2]
     else:
         return line[:-1]
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs