- Fix error in ConfigBase handling (bsc#1209401)

- add hplip-base-fix-error-in-ConfigBase-handling.patch

- Fix python error on SLE12-SP3 (bsc#1209401, bsc#1234745)
  - add hplip-base-replace-f-string-with-string.format-for-p.patch

OBS-URL: https://build.opensuse.org/package/show/Printing/hplip?expand=0&rev=260
This commit is contained in:
Martin Wilck 2025-01-24 09:10:34 +00:00 committed by Git OBS Bridge
parent 4291a2a098
commit 55c3139c15
4 changed files with 82 additions and 0 deletions

View File

@ -0,0 +1,29 @@
From 2a13a15b7f533606667e8586ff5ed736f038f2e8 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Thu, 23 Jan 2025 12:47:43 +0100
Subject: [PATCH 1/2] hplip/base: fix error in ConfigBase handling
The code in question was apparently meant to handle the replacement
of ConfigParser.readfp() by ConfigParser.read_file(). But the code
is obviously broken, trying read_file() first and then read_file()
again.
---
base/g.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/base/g.py b/base/g.py
index 0d1c986..c1f5d24 100644
--- a/base/g.py
+++ b/base/g.py
@@ -128,7 +128,7 @@ class ConfigBase(object):
try:
fp = open(self.filename, "r")
try:
- self.conf.read_file(fp)
+ self.conf.readfp(fp)
except AttributeError as e:
log.error(f"Error: {e}. Retrying with read_file")
try:
--
2.48.1

View File

@ -0,0 +1,32 @@
From f1fef1ed07951fbc6e81d90ab43172974979eeeb Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Wed, 22 Jan 2025 17:44:04 +0100
Subject: [PATCH 2/2] hplip/base: replace f-string with string.format for
python2 compatibility
---
base/g.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/base/g.py b/base/g.py
index c1f5d24..a3b6191 100644
--- a/base/g.py
+++ b/base/g.py
@@ -130,12 +130,12 @@ class ConfigBase(object):
try:
self.conf.readfp(fp)
except AttributeError as e:
- log.error(f"Error: {e}. Retrying with read_file")
+ log.error("Error: {0}. Retrying with read_file".format(e))
try:
# Attempting to use read_file as a fallback
self.conf.read_file(fp)
except Exception as e:
- log.error(f"Reading file with read_file also failed. Error: {e}")
+ log.error("Reading file with read_file also failed. Error: {0}".format(e))
except configparser.MissingSectionHeaderError:
print("")
log.error("Found No Section in %s. Please set the http proxy for root and try again." % self.filename)
--
2.48.1

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Thu Jan 23 11:52:26 UTC 2025 - Martin Wilck <mwilck@suse.com>
- Fix error in ConfigBase handling (bsc#1209401)
- add hplip-base-fix-error-in-ConfigBase-handling.patch
-------------------------------------------------------------------
Wed Jan 22 16:52:17 UTC 2025 - Martin Wilck <mwilck@suse.com>
- Fix python error on SLE12-SP3 (bsc#1209401, bsc#1234745)
- add hplip-base-replace-f-string-with-string.format-for-p.patch
-------------------------------------------------------------------
Tue Jan 14 11:34:35 UTC 2025 - Martin Wilck <mwilck@suse.com>

View File

@ -115,6 +115,9 @@ Patch602: hplip-scan-hpaio-include.patch
Patch603: hplip-scan-orblite-c99.patch
Patch604: hplip-sclpml-strcasestr.patch
Patch605: hplip-hpaio-gcc14.patch
Patch606: hplip-base-fix-error-in-ConfigBase-handling.patch
# Compatibility patches for old SUSE releases
Patch700: hplip-base-replace-f-string-with-string.format-for-p.patch
%if %use_qt5
BuildRequires: %{pymod qt5-devel}
@ -378,6 +381,12 @@ This sub-package is only required by developers.
%patch -P 603 -p1
%patch -P 604 -p1
%patch -P 605 -p1
%patch -P 606 -p1
%if 0%{?suse_version} < 1500
# python2 compatibility
%patch -P 700 -p1
%endif
# replace "env" shebang and "/usr/bin/python" with real executable
find . -name '*.py' -o -name pstotiff | \
xargs -n 1 sed -i '1s,^#!\(%{_bindir}/env python\|%{_bindir}/python\),#!%{pyexe},'