]> git.lyx.org Git - features.git/commit
Make the lyx2lyx code compatible between python2 and python3.
authorJosé Matos <jamatos@lyx.org>
Wed, 5 Jun 2019 13:06:09 +0000 (14:06 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:33 +0000 (15:48 +0200)
commit728eabb69c3ac3923d67277f052555ff84b5728b
treeee7cfe512143c19ce7b877924cc7454abeb90605
parent8e4d56b735eff2258dcd5383237b0048a862884b
Make the lyx2lyx code compatible between python2 and python3.

FWIW this code is important for very old versions of lyx, older than 1.1.5 (released 19 years ago - 2000/06/06).

Funny fact of the day, byte strings do not behave as regular strings in python3 when taking and index.
To get a sub-string we need to pass a range, a integer index will not work as it happens in a regular string:

$ ipython3
...
In [30]: line
Out[30]: b'#This file was created by <mike> Tue Jan 25 10:36:51 2000'

In [31]: line[0]
Out[31]: 35

In [32]: line[0:1]
Out[32]: b'#'

The range notations works for both byte and regular strings in python 3, and it also works in python 2.
Thus the change is simple and effective. In any case I should confess that I was quite surprised by this. :-)
lib/lyx2lyx/LyX.py