From 30d421400539ebef835aa5956c7aa9068d9e0601 Mon Sep 17 00:00:00 2001 From: Olav Vitters Date: Mon, 11 May 2020 10:36:34 +0200 Subject: assume output is utf-8 (as per some Python verison) --- mgagnome | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mgagnome b/mgagnome index 8c80bd5..321916a 100755 --- a/mgagnome +++ b/mgagnome @@ -395,9 +395,9 @@ class SpecFile(): def _sources_and_patches(self, flag=None): os.chdir(self.cwd) rpm.delMacro("_topdir") - rpm.addMacro("_topdir", self.cwd) + rpm.addMacro("_topdir", str(self.cwd)) trans_set = rpm.ts() - spec = trans_set.parseSpec(self.path) + spec = trans_set.parseSpec(str(self.path)) try: srclist = spec.sources if isinstance(spec.sources, (list, tuple)) \ else spec.sources() @@ -951,10 +951,10 @@ class SpecFile(): Parses the spec file to do this, so any macros are expanded""" rpm.delMacro("_topdir") - rpm.addMacro("_topdir", self.cwd) + rpm.addMacro("_topdir", str(self.cwd)) trans_set = rpm.ts() try: - spec = trans_set.parseSpec(self.path) + spec = trans_set.parseSpec(str(self.path)) except ValueError as exc: # Reraise this into a more specific exception raise SpecFileError from exc @@ -2211,7 +2211,7 @@ def cmd_parse_ftp_release_list(options): if error: # XXX - ugly contents.seek(0) - lastline = contents.read().decode('utf-8').rstrip().splitlines()[-1] + lastline = contents.read().rstrip().splitlines()[-1] # Remove things like "ERROR: " and so on from the last line lastline = re.sub(r'^(?:[^ :]+:\s+)+', '', lastline) # Remove things like " - " (youri output from mgarepo submit) @@ -2243,7 +2243,7 @@ def cmd_parse_ftp_release_list(options): msg = email.message_from_file(sys.stdin) if options.mail: - stdout = tempfile.TemporaryFile() + stdout = tempfile.TemporaryFile(mode='w+t', encoding='utf-8') stderr = stdout else: stdout = sys.stdout @@ -2264,7 +2264,7 @@ def cmd_parse_ftp_release_list(options): packages = Downstream().get_downstream_from_upstream(module, version) except (ValueError, SpecFileError) as exc: #print(bytes("ERROR: %s" % str(exc), 'UTF-8'), file=stderr) - stderr.write(bytes("ERROR: %s" % str(exc), 'UTF-8')) + stderr.write("ERROR: %s" % str(exc)) if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True) -- cgit v1.2.1