[LyX/2.3.x] Attempt to fix #11457
Richard Kimberly Heck
rikiheck at lyx.org
Wed Oct 30 23:13:39 UTC 2019
commit b1860e301acfef3586143d240ae00716beb8c61c
Author: José Matos <jamatos at lyx.org>
Date: Tue May 28 16:22:32 2019 +0100
Attempt to fix #11457
In python 3 the colors need to be strings and not bytes:
This was the equivalent of
>> print("%s" % b"1")
"b'1'"
since the colors were bytes the call to dvipng was something like
dvipng -Ttight -depth -height -D 115 -fg "b'rgb 0.937255 0.941176 0.945098'" -bg "b'rgb 0.137255 0.149020 0.160784'" "lyxpreviewxBJEqm.dvi"
Note the "b'rgb after both -fg and -bg that wrecked havoc and thus dvipng failed. That was the difference between python2 and python3 calls.
(cherry picked from commit 8dd31803b16d1fb6b30772955188c3595437f64a)
---
lib/scripts/lyxpreview2bitmap.py | 6 ++++++
status.23x | 2 ++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/lib/scripts/lyxpreview2bitmap.py b/lib/scripts/lyxpreview2bitmap.py
index e4bf131..ecefdaf 100755
--- a/lib/scripts/lyxpreview2bitmap.py
+++ b/lib/scripts/lyxpreview2bitmap.py
@@ -373,6 +373,7 @@ def main(argv):
dir, latex_file = os.path.split(input_path)
# Echo the settings
+ progress("Running Python %s" % str(sys.version_info[:3]))
progress("Starting %s..." % script_name)
progress("Output format: %s" % output_format)
progress("Foreground color: %s" % fg_color)
@@ -394,6 +395,11 @@ def main(argv):
fg_color_dvipng = make_texcolor(fg_color, False)
bg_color_dvipng = make_texcolor(bg_color, False)
+ # For python > 2 convert bytes to string
+ if not PY2:
+ fg_color_dvipng = fg_color_dvipng.decode('ascii')
+ bg_color_dvipng = bg_color_dvipng.decode('ascii')
+
# External programs used by the script.
latex = find_exe_or_terminate(latex or latex_commands)
bibtex = find_exe(bibtex or bibtex_commands)
diff --git a/status.23x b/status.23x
index a9f8233..93202c5 100644
--- a/status.23x
+++ b/status.23x
@@ -162,6 +162,8 @@ What's new
- Fix TeX file listing with the Nix package manager.
+- Fix Python detection routines, and so instant preview on some platforms
+ (bug 11282).
* DOCUMENTATION AND LOCALIZATION
More information about the lyx-cvs
mailing list