Fwd: String/Bytes Problem in layout2layout.py

Pavel Sanda sanda at lyx.org
Wed Dec 29 14:52:29 UTC 2021


Jose,

are the proposed changes sensible?
I remember there were flowing similar patches to python codebase before.

Pavel
----- Forwarded message from "Leo L. Schwab" <ewhac at ewhac.org> -----

From: "Leo L. Schwab" <ewhac at ewhac.org>
To: Debian Bug Tracking System <submit at bugs.debian.org>
Subject: Bug#1002821: lyx-common: String/Bytes Problem in layout2layout.py

Package: lyx-common
Version: 2.3.6-1
Severity: normal
Tags: patch upstream
X-Debbugs-Cc: ewhac at ewhac.org

Dear Maintainer,

	Discovered this while trying to use Editorium's LyXBook modules.
layout2layout.py was konking out with "TypeError: cannot use a bytes
pattern on a string-like object."  After a bunch of debugging, I found
some strings in the script that hadn't been bytes-ified, which seemed to
fix the problem.  Patch attached.

					Schwab


-- System Information:
Debian Release: bookworm/sid
  APT prefers testing-security
  APT policy: (500, 'testing-security'), (500, 'unstable'), (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.15.0-2-amd64 (SMP w/12 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages lyx-common depends on:
ii  python3     3.9.8-1
ii  tex-common  6.17

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

lyx-common suggests no packages.

-- no debconf information

--- /usr/share/lyx/scripts/layout2layout.py	2020-12-01 02:33:35.000000000 -0800
+++ ./layout2layout.py	2021-12-29 01:04:59.614016427 -0800
@@ -484,8 +484,8 @@
                 i += 1
                 continue
             col  = match.group(2)
-            if col == "collapsable":
-                lines[i] = match.group(1) + "collapsible"
+            if col == b"collapsable":
+                lines[i] = match.group(1) + b"collapsible"
             i += 1
             continue
 
@@ -703,7 +703,7 @@
             # Insert the required number of arguments at the end of the style definition
             match = re_End.match(lines[i])
             if match:
-                newarg = ['']
+                newarg = [b'']
                 # First the optionals (this is the required order pre 2.1)
                 if opts > 0:
                     if opts == 1:
@@ -1153,7 +1153,7 @@
             if latextype == b"item_environment" and label.lower() == b"counter_enumi":
                 lines[labeltype_line] = re_LabelType.sub(b'\\1\\2\\3Enumerate', lines[labeltype_line])
                 # Don't add the LabelCounter line later
-                counter = ""
+                counter = b""
 
             # Replace
             #
@@ -1227,12 +1227,12 @@
     if options.input_file:
         source = open(options.input_file, 'rb')
     else:
-        source = sys.stdin
+        source = sys.stdin.buffer
 
     if options.output_file:
         output = open(options.output_file, 'wb')
     else:
-        output = sys.stdout
+        output = sys.stdout.buffer
 
     if options.format > currentFormat:
         error("Format %i does not exist" % options.format);


----- End forwarded message -----


More information about the lyx-devel mailing list