summaryrefslogtreecommitdiffhomepage
path: root/gbp
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-08-02 01:32:36 -0300
committerGuido Günther <agx@sigxcpu.org>2017-08-02 01:32:36 -0300
commit80fdad64055e17bd8b88b08353c0ea69105b2241 (patch)
tree5acba8e245a1d93790f616329621b6feacf12657 /gbp
parent1b5a47f4bda5d8809998750c3a35b4e02c8b2851 (diff)
command_wrappers: port to Python3
Diffstat (limited to 'gbp')
-rw-r--r--gbp/command_wrappers.py10
-rw-r--r--gbp/deb/changelog.py10
2 files changed, 12 insertions, 8 deletions
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py
index bf26bff9..43484a13 100644
--- a/gbp/command_wrappers.py
+++ b/gbp/command_wrappers.py
@@ -1,6 +1,6 @@
# vim: set fileencoding=utf-8 :
#
-# (C) 2007,2009,2015 Guido Guenther <agx@sigxcpu.org>
+# (C) 2007,2009,2015,2017 Guido Guenther <agx@sigxcpu.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@@ -119,6 +119,10 @@ class Command(object):
stdout=stdout_arg,
stderr=stderr_arg)
(self.stdout, self.stderr) = popen.communicate()
+ if self.stdout is not None:
+ self.stdout = self.stdout.decode()
+ if self.stderr is not None:
+ self.stderr = self.stderr.decode()
except OSError as err:
self.err_reason = "execution failed: %s" % str(err)
self.retcode = 1
@@ -210,13 +214,13 @@ class Command(object):
... extra_env={'LC_ALL': 'C'})
>>> c.call(["--version"])
0
- >>> c.stdout.decode('utf-8').startswith('true')
+ >>> c.stdout.startswith('true')
True
>>> c = Command("/bin/false", capture_stdout=True,
... extra_env={'LC_ALL': 'C'})
>>> c.call(["--help"])
1
- >>> c.stdout.decode('utf-8').startswith('Usage:')
+ >>> c.stdout.startswith('Usage:')
True
"""
try:
diff --git a/gbp/deb/changelog.py b/gbp/deb/changelog.py
index ac867a93..58100a96 100644
--- a/gbp/deb/changelog.py
+++ b/gbp/deb/changelog.py
@@ -97,11 +97,11 @@ class ChangeLog(object):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- (output, errors) = cmd.communicate(self._contents)
+ (stdout, stderr) = cmd.communicate(self._contents.encode())
if cmd.returncode:
raise ParseChangeLogError("Failed to parse changelog. "
- "dpkg-parsechangelog said:\n%s" % (errors, ))
- return output
+ "dpkg-parsechangelog said:\n%s" % stderr.decode().strip())
+ return stdout.decode()
def _parse(self):
"""Parse a changelog based on the already read contents."""
@@ -124,8 +124,8 @@ class ChangeLog(object):
self._cp = cp
def _read(self):
- with open(self.filename) as f:
- self._contents = f.read()
+ with open(self.filename) as f:
+ self._contents = f.read()
def __getitem__(self, item):
return self._cp[item]