From 2446d4a6061b65c498b4ad78b507e640553f08f8 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 May 2018 16:12:34 +0100 Subject: fix Python 3 uses of subprocess.check_output https://stackoverflow.com/questions/15817420/subprocess-and-type-str-doesnt-support-the-buffer-api/15817457#15817457 --- git_deps/detector.py | 4 ++-- git_deps/gitutils.py | 8 +++++--- git_deps/listener/cli.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'git_deps') diff --git a/git_deps/detector.py b/git_deps/detector.py index 3111a38..df5b001 100644 --- a/git_deps/detector.py +++ b/git_deps/detector.py @@ -169,7 +169,7 @@ class DependencyDetector(object): '-L', "%d,+%d" % (hunk.old_start, hunk.old_lines), parent.hex, '--', path ] - blame = subprocess.check_output(cmd) + blame = subprocess.check_output(cmd, universal_newlines=True) dependent_sha1 = dependent.hex if dependent_sha1 not in self.dependencies: @@ -288,7 +288,7 @@ class DependencyDetector(object): cmd = ['git', 'merge-base', sha1, branch_sha1] # self.logger.debug(" ".join(cmd)) - out = subprocess.check_output(cmd).strip() + out = subprocess.check_output(cmd, universal_newlines=True).strip() self.logger.debug(" merge-base returned: %s" % out[:8]) result = out == sha1 self.logger.debug(" %s" % result) diff --git a/git_deps/gitutils.py b/git_deps/gitutils.py index f7b5470..f699551 100644 --- a/git_deps/gitutils.py +++ b/git_deps/gitutils.py @@ -15,7 +15,7 @@ class GitUtils(object): # we will be able to do this via pygit2. cmd = ['git', 'rev-parse', '--short', sha1] # cls.logger.debug(" ".join(cmd)) - out = subprocess.check_output(cmd).strip() + out = subprocess.check_output(cmd, universal_newlines=True).strip() # cls.logger.debug(out) return out @@ -39,7 +39,8 @@ class GitUtils(object): # cls.logger.debug(" ".join(cmd)) out = None try: - out = subprocess.check_output(cmd, stderr=subprocess.STDOUT) + out = subprocess.check_output( + cmd, stderr=subprocess.STDOUT, universal_newlines=True) except subprocess.CalledProcessError as e: if e.output.find('No tags can describe') != -1: return '' @@ -77,7 +78,8 @@ class GitUtils(object): @classmethod def rev_list(cls, rev_range): cmd = ['git', 'rev-list', rev_range] - return subprocess.check_output(cmd).strip().split('\n') + return subprocess.check_output(cmd, universal_newlines=True) \ + .strip().split('\n') @classmethod def ref_commit(cls, repo, rev): diff --git a/git_deps/listener/cli.py b/git_deps/listener/cli.py index 285c622..01bf4df 100644 --- a/git_deps/listener/cli.py +++ b/git_deps/listener/cli.py @@ -46,7 +46,7 @@ class CLIDependencyListener(DependencyListener): 'log', '-n1', dependency_sha1 ] - print(subprocess.check_output(cmd)) + print(subprocess.check_output(cmd, universal_newlines=True)) # dependency = detector.get_commit(dependency_sha1) # print(dependency.message + "\n") -- cgit