All unit tests pass on both Python 2 and 3, regardless of the new_write switch at the start of leoAtFile.py. However, this must be considered a dangerous change until it is tested more thoroughly. Please make *sure* you make backups of any data you handle with the new code.
Please report *any* file-related problems immediately. Otoh, I have run all the tests I can think of, and I am happily eating my own dog food. The checking log gives the highlights: QQQ Worked on (but did *not* fix) bug 1223383: Garbled text with BOM-marked files. Added new_write master switch in leoAtFile.py. When new_write is True: - Leo no longer writes a temporary output file. - at.replaceTargetFileIfDifferent calls the new at.create method to write the target file. - onl simply writes '\n'. Conversion to the desired newline happens only in at.create. Important: writing utf-16 files appears to work, but reading utf-16 files does not. There are problems decoding utf-16 string in at.readline. Possibly reading the entire file and converting to unicode might work. QQQ Notes: 1. The new code is definitely the wave of the future: it is substantially simpler because all intermediate writes go to a g.fileLikeObject rather than an actual file. And there are other advantages: - The cursed newline problem is handled in only one place, namely the new at.create method. - Similarly, the only call to g.toEncodedString occurs in at.create. This ensures that BOM's are written only at the start of a file. 2. Reading utf-16 encode files still does not work. In particular, at.readline does not recognize newlines. It's possible that file.readline (which at.readline uses) really doesn't handle utf-16 encoded newlines properly. It might be possible to work around that problem by converting the entire input file to unicode first, rather than converting the file on a line-by-line basis. We shall see. 3. To repeat, the new code is worth having even if the problems with utf-16 can not be solved. In that case, the advice would be to convert utf-16 data to utf-8 data, using the simple python script in the original bug report. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
