From: Georg Baum Date: Sat, 11 Jun 2016 12:45:18 +0000 (+0200) Subject: Improve comments and add missing decoding call X-Git-Tag: 2.3.0alpha1~1500 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=72c6602b13b0fb09f80fa742266c78a50e8bb73c;p=features.git Improve comments and add missing decoding call We do already fill the first line of the body in the first pass, so the body has to be converted to the correct encoding as well. --- diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index fa2bbba619..d98d765667 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -280,17 +280,20 @@ class LyX_base: """Reads a file into the self.header and self.body parts, from self.input.""" + # First pass: Read header to determine file encoding while True: line = self.input.readline() if not line: - self.error("Invalid LyX file.") + # eof found before end of header + self.error("Invalid LyX file: Missing body.") line = trim_eol(line) if check_token(line, '\\begin_preamble'): while 1: line = self.input.readline() if not line: - self.error("Invalid LyX file.") + # eof found before end of header + self.error("Invalid LyX file: Missing body.") line = trim_eol(line) if check_token(line, '\\end_preamble'): @@ -345,6 +348,8 @@ class LyX_base: self.header[i] = self.header[i].decode(self.encoding) for i in range(len(self.preamble)): self.preamble[i] = self.preamble[i].decode(self.encoding) + for i in range(len(self.body)): + self.body[i] = self.body[i].decode(self.encoding) # Read document body while 1: