Package: lyx-common
Version: 2.3.3-1
Severity: important
Tags: patch

Dear Maintainer,

I was porting one of my packages (pycode-browser) from Python2
to Python3, in order to close the bug report #937407 filed by
Matthias Klose, "Python2 removal in sid/bullseye".

The build raised a series of errors, due to the script
convertDefault.py, which is not properly ported to Python3:

----------- for example---8<-----------------------------------
support/Systemcall.cpp (276): Systemcall: 'python3 -tt
"/usr/share/lyx/scripts/convertDefault.py" png
"/tmp/lyx_tmpdir.SihlAXIKJELT/lyx_tmpbuf0/47_home_georgesk_developpement_pycode-
browser_collab_pycode-browser_pybooksrc_pics_lsfit.png" eps
"/tmp/lyx_tmpdir.SihlAXIKJELT/lyx_tmpbuf0/47_home_georgesk_developpement_pycode-
browser_collab_pycode-browser_pybooksrc_pics_lsfit.eps"' finished with exit
code 1
Traceback (most recent call last):
  File "/usr/share/lyx/scripts/convertDefault.py", line 38, in <module>
    output = output.decode()
AttributeError: 'str' object has no attribute 'decode'
-----------------------------8<--------------------------------

The reason for this misbehavior is that either with Python2 or
with Python3, os.popen deals with 'str' data, never 'bytes' data.

So, lines 37 and 38 of the script must be erased.

Here is a short diff which fixes this issue:

-----------------------8<----------------------------------
--- a/convertDefault.py 2019-09-01 18:16:59.833826411 +0200
+++ b/convertDefault.py 2019-09-01 18:18:38.622524626 +0200
@@ -33,9 +33,8 @@
     command = 'convert'
     fout = os.popen('convert -version 2>&1')
     output = fout.readline()
+    # assert type(output)==type("") # os.popen deals with strings in Python3
     fout.close()
-if not PY2:
-    output = output.decode()

 version = re_version.match(output)
 -----------------------8<----------------------------------

Best regards,                     Georges.



-- System Information:
Debian Release: 10.0
  APT prefers stable
  APT policy: (900, 'stable'), (499, 'testing'), (400, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-5-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), 
LANGUAGE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages lyx-common depends on:
ii  python3     3.7.3-1
ii  tex-common  6.11

Versions of packages lyx-common recommends:
ii  lyx  2.3.3-1

lyx-common suggests no packages.

-- debconf-show failed
--- a/convertDefault.py 2019-09-01 18:16:59.833826411 +0200
+++ b/convertDefault.py 2019-09-01 18:18:38.622524626 +0200
@@ -33,9 +33,8 @@
     command = 'convert'
     fout = os.popen('convert -version 2>&1')
     output = fout.readline()
+    # assert type(output)==type("") # os.popen deals with strings in Python3
     fout.close()
-if not PY2:
-    output = output.decode()
 
 version = re_version.match(output)
 

Reply via email to