From 08a747a75027ed09fb62e6d30983aa3b563156b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Matos?= Date: Sun, 5 Jan 2025 12:16:58 +0000 Subject: [PATCH] Fix typo that make the conversion not working The reason to change was that format is a builtin function in Python. By redefining it we are simply overriding it and so it is not a problem although not elegant. Another issue in this file is `match` that become a contextual keyword in Python 3.10. Again it is not elegant although it is allowed. --- lib/scripts/layout2layout.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index cc3adaaa03..5db0c9e41b 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -562,15 +562,15 @@ def convert(lines, end_format): match = re_Format.match(lines[i]) if match: formatline = i - format_ = int(match.group(4)) - if 1 < format_ < end_format: - lines[i] = b"Format %d" % (format_ + 1) + format = int(match.group(4)) + if 1 < format < end_format: + lines[i] = b"Format %d" % (format + 1) only_comment = 0 - elif format_ == end_format: + elif format == end_format: # nothing to do - return format_ + return format else: - error(f'Cannot convert file format {format_} to {end_format}') + error(f'Cannot convert file format {format} to {end_format}') else: lines.insert(i, b"Format 2") only_comment = 0