On 2019-08-29, Scott Kostyshak wrote: > On Thu, Aug 29, 2019 at 12:20:56PM -0000, Guenter Milde wrote:
... >> I did not follow this and never use preview, so how can I reproduce? > First enable preview by doing > Tools > Preferences > Display > and set Instant preview to "On" > Then, save the preferences and exit LyX. Then, just open the following > file in LyX from the terminal: > lyx lib/examples/es/Modules/Linguistics.lyx > I get the messages (without doing anything) after 3 seconds. > Can you reproduce? I can reproduce. Please try the patch below (the idea is to keep the "filter_pages()" function "encoding-agnostic" by using byte-strings): * Save the mail (in mbox or text format) to "/tmp/preview.patch", say. * In the repo: git apply /tmp/preview.patch * Test. Thanks, Günter Exec: git 'diff' 'lyxpreview_tools.py' 2>&1 Dir: /usr/local/src/lyx/lib/scripts/ diff --git a/lib/scripts/lyxpreview_tools.py b/lib/scripts/lyxpreview_tools.py index 91cc4d6ab1..2f8c2f8d64 100644 --- a/lib/scripts/lyxpreview_tools.py +++ b/lib/scripts/lyxpreview_tools.py @@ -219,16 +219,16 @@ def write_metrics_info(metrics_info, metrics_file): # Reads a .tex files and create an identical file but only with # pages whose index is in pages_to_keep def filter_pages(source_path, destination_path, pages_to_keep): - def_re = re.compile(r"(\\newcommandx|\\renewcommandx|\\global\\long\\def)(\\[a-zA-Z]+)(.+)") - source_file = open(source_path, "r") - destination_file = open(destination_path, "w") + def_re = re.compile(rb"(\\newcommandx|\\renewcommandx|\\global\\long\\def)(\\[a-zA-Z]+)(.+)") + source_file = open(source_path, "rb") + destination_file = open(destination_path, "wb") page_index = 0 skip_page = False macros = [] for line in source_file: # We found a new page - if line.startswith("\\begin{preview}"): + if line.startswith(b"\\begin{preview}"): page_index += 1 # If the page index isn't in pages_to_keep we don't copy it skip_page = page_index not in pages_to_keep @@ -240,12 +240,12 @@ def filter_pages(source_path, destination_path, pages_to_keep): macroname = match.group(2) if not macroname in macros: macros.append(macroname) - if definecmd == "\\renewcommandx": - line = line.replace(definecmd, "\\newcommandx") + if definecmd == b"\\renewcommandx": + line = line.replace(definecmd, b"\\newcommandx") destination_file.write(line) # End of a page, we reset the skip_page bool - if line.startswith("\\end{preview}"): + if line.startswith(b"\\end{preview}"): skip_page = False destination_file.close()