summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbiao716.wang <biao716.wang@samsung.com>2022-11-30 18:40:17 +0900
committerbiao716.wang <biao716.wang@samsung.com>2022-11-30 18:40:21 +0900
commit268f9f0c7823e856f7f63494a4e12dce5ec8cbbd (patch)
tree0a1d694a00dfef15d19dc091f70371c70bb42fd0
parent6f7ef991f742eb5c5226272ca28edd71a2424143 (diff)
downloadgit-buildpackage-268f9f0c7823e856f7f63494a4e12dce5ec8cbbd.tar.gz
git-buildpackage-268f9f0c7823e856f7f63494a4e12dce5ec8cbbd.tar.bz2
git-buildpackage-268f9f0c7823e856f7f63494a4e12dce5ec8cbbd.zip
fix run error for re.sub(): KeyError: '\S'
It seems backslash handling changed in Python3.8: https://docs.python.org/3.8/library/re.html Change-Id: I43c9e9baa13598015fb9ef801bd435e78945c309 Signed-off-by: biao716.wang <biao716.wang@samsung.com>
-rw-r--r--gbp/git/repository.py18
-rw-r--r--gbp/scripts/common/pq.py2
2 files changed, 10 insertions, 10 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 3dfecdc1..64053a55 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -101,7 +101,7 @@ class GitRepository(object):
else:
out, dummy, ret = self._git_inout('rev-parse', ['--show-toplevel'],
capture_stderr=True)
- self._path = os.path.abspath(out.strip())
+ self._path = os.path.abspath(out.decode().strip())
def __init__(self, path):
self._path = os.path.abspath(path)
@@ -111,8 +111,8 @@ class GitRepository(object):
capture_stderr=True)
cdup = out.strip().decode(sys.getfilesystemencoding())
if ret:
- raise GitRepositoryError("No Git repository at '%s': '%s'" % (self.path, out))
- self._bare = False if out.strip() != 'true' else True
+ raise GitRepositoryError("No Git repository at '%s': '%s'" % (self.path, out.decode().strip()))
+ self._bare = False if out.decode().strip() != 'true' else True
self._check_dirs()
@@ -183,8 +183,8 @@ class GitRepository(object):
if not cwd:
cwd = self.path
ret = 0
- stdout = ''
- stderr = ''
+ stdout = b''
+ stderr = b''
try:
for outdata in self.__git_inout(command, args, input, extra_env,
cwd, capture_stderr,
@@ -207,7 +207,7 @@ class GitRepository(object):
"""
if not cwd:
cwd = self.path
- stderr = ''
+ stderr = b''
try:
for outdata in self.__git_inout(command, args, stdin, extra_env,
cwd, capture_stderr, True):
@@ -266,8 +266,8 @@ class GitRepository(object):
if w_ind > len(stdin):
rm_polled_fd(popen.stdin, in_fds)
# Read in chunks of 4k
- stdout = popen.stdout.read(4096) if popen.stdout in ready[0] else ''
- stderr = popen.stderr.read(4096) if popen.stderr in ready[0] else ''
+ stdout = popen.stdout.read(4096) if popen.stdout in ready[0] else b''
+ stderr = popen.stderr.read(4096) if popen.stderr in ready[0] else b''
if popen.stdout in ready[0] and not stdout:
rm_polled_fd(popen.stdout, out_fds)
if popen.stderr in ready[0] and not stderr:
@@ -1223,7 +1223,7 @@ class GitRepository(object):
remotes = {}
for rem in stdout.splitlines():
- name, url_urltype = rem.remote.decode().strip().split('\t', 1)
+ name, url_urltype = rem.decode().strip().split('\t', 1)
url, urltype = url_urltype.rsplit(' ', 1)
urltype = urltype.strip('()')
if not name in remotes:
diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py
index 0ea9f9e8..95516c08 100644
--- a/gbp/scripts/common/pq.py
+++ b/gbp/scripts/common/pq.py
@@ -49,7 +49,7 @@ def pq_branch_match(branch, pq_fmt_str):
>>> pq_branch_match('foo/bar/1.0/pq', 'foo/%(br)s/%(ver)s/pq').groupdict()
{'ver': '1.0', 'br': 'bar'}
"""
- pq_re = '^%s$' % re.sub('%\(([a-z_\-]+)\)s', r'(?P<\1>\S+)', pq_fmt_str)
+ pq_re = '^%s$' % re.sub('%\(([a-z_\-]+)\)s', r'(?P<\1>\\S+)', pq_fmt_str)
return re.match(pq_re, branch)