Skip to content

Commit ba32c3e

Browse files
committed
Fix two Python 3 incompatibilities in the zypper module
process.stdout is of type 'bytes' in Python 3 and needs to be decoded to get a 'string' object. Ticket: CFE-3364 Changelog: The zypper module is now fully compatible with Python 3
1 parent 981cb75 commit ba32c3e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

modules/packages/zypper.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def subprocess_call(cmd, stdout=None, stderr=None):
108108
process = subprocess_Popen(cmd, stdout, stderr)
109109
outs, errs = process.communicate()
110110
if stderr == subprocess.PIPE:
111-
lines = [line for line in errs.decode("utf-8").splitlines()]
111+
lines = [line for line in errs.decode().splitlines()]
112112
if len(lines):
113113
printed_error = "ErrorMessage=" + " ".join(lines)
114114
sys.stdout.write(printed_error)
@@ -160,7 +160,7 @@ def list_updates(online):
160160

161161
process = subprocess_Popen([zypper_cmd] + zypper_options + online_flag + ["list-updates"], stdout=subprocess.PIPE)
162162

163-
for line in process.stdout:
163+
for line in (line.decode() for line in process.stdout):
164164

165165
# Zypper's output looks like:
166166
#
@@ -201,7 +201,7 @@ def one_package_argument(name, arch, version, is_zypper_install):
201201
if is_zypper_install:
202202
process = subprocess_Popen([rpm_cmd, "--qf", "%{arch}\n",
203203
"-q", name], stdout=subprocess.PIPE)
204-
existing_archs = [line.rstrip() for line in process.stdout]
204+
existing_archs = [line.decode().rstrip() for line in process.stdout]
205205
process.wait()
206206
if process.returncode == 0 and existing_archs:
207207
exists = True

0 commit comments

Comments
 (0)