From 2cc4adede1c248740b5cded15bf5b3ef02f97e20 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 21 Jul 2023 09:38:06 +0200 Subject: Fix errors when use_git_credential is enabled That feature was broken since the switch to Python 3 --- git-bz | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/git-bz b/git-bz index 62c5461..ebe2fe1 100755 --- a/git-bz +++ b/git-bz @@ -1029,6 +1029,7 @@ class BugServer(object): "host={host}\npath={path}\n" \ "\n".format(protocol=protocol, host=self.host, path=self.path.lstrip('/')) process = Popen(["git", "credential", "fill"], + text=True, stdout=PIPE, stdin=PIPE) git_credential_output, error = process.communicate(git_credential_input) @@ -1050,12 +1051,12 @@ class BugServer(object): if self.use_git_credential: # If page body doesn't contain 'Invalid Login' we consider it a # successful login - match = re.search('Invalid Login', res.read()) + match = re.search('Invalid Login', res.read().decode('utf-8')) if match: - process = Popen(["git", "credential", "reject"], stdin=PIPE) + process = Popen(["git", "credential", "reject"], stdin=PIPE, text=True) process.communicate(git_credential_output) else: - process = Popen(["git", "credential", "approve"], stdin=PIPE) + process = Popen(["git", "credential", "approve"], stdin=PIPE, text=True) process.communicate(git_credential_output) self.cookiestring = res.getheader('set-cookie') -- cgit From 96a4dc0327e822fa6d2ceef5fe44af253e2bf4a6 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 3 Jan 2024 10:03:14 +0000 Subject: Escape re match escapes for python3 --- git-bz | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/git-bz b/git-bz index ebe2fe1..2dc3599 100755 --- a/git-bz +++ b/git-bz @@ -222,7 +222,7 @@ def rev_list_commits(*args, **kwargs): result = [] for i in range(0, len(lines), 2): - m = re.match("commit\s+([A-Fa-f0-9]+)", lines[i]) + m = re.match("commit\\s+([A-Fa-f0-9]+)", lines[i]) if not m: raise RuntimeError("Can't parse commit it '%s'", lines[i]) commit_id = m.group(1) @@ -339,7 +339,7 @@ def split_local_config(config_text): line = line.strip() if line == "": continue - m = re.match("([a-zA-Z0-9-]+)\s*=\s*(.*)", line) + m = re.match("([a-zA-Z0-9-]+)\\s*=\\s*(.*)", line) if not m: die("Bad config line '%s'" % line) @@ -1902,7 +1902,7 @@ def do_apply(*args): lines = edit_template(template.getvalue()) patches = [] for line in lines: - match = re.match('^(\d+)', line) + match = re.match('^(\\d+)', line) if match: pid = int(match.group(1)) if pid not in patches_by_id: @@ -1985,7 +1985,7 @@ def strip_bug_url(bug, commit_body): # using commit body in as a comment; doing it by stripping right before # posting means that we are robust against someone running add-url first # and attach second. - pattern = "\s*" + re.escape(bug.get_url()) + "\s*$" + pattern = "\\s*" + re.escape(bug.get_url()) + "\\s*$" return re.sub(pattern, "", commit_body) @@ -2038,19 +2038,19 @@ def edit_attachment_comment(bug, initial_description, initial_body): depends = [] def filter_line(line): - m = re.match("^\s*Obsoletes\s*:\s*([\d]+)", line) + m = re.match("^\\s*Obsoletes\\s*:\\s*([\\d]+)", line) if m: obsoletes.append(int(m.group(1))) return False - m = re.match("^\s*Status\s*:\s*(.+)", line) + m = re.match("^\\s*Status\\s*:\\s*(.+)", line) if m: statuses.append(m.group(1)) return False - m = re.match("^\s*Patch-complexity\s*:\s*(.+)", line) + m = re.match("^\\s*Patch-complexity\\s*:\\s*(.+)", line) if m: patch_complexities.append(m.group(1)) return False - m = re.match("^\s*Depends\s*:\s*([Bb][Uu][Gg])?\s*(\d+)", line) + m = re.match("^\\s*Depends\\s*:\\s*([Bb][Uu][Gg])?\\s*(\\d+)", line) if m: depends.append(m.group(2)) return False @@ -2293,24 +2293,24 @@ def edit_bug(bug, applied_commits=None, fix_commits=None): lines = edit_template(template.getvalue()) def filter_line(line): - m = re.match("^\s*Resolution\s*:\s*(\S+)", line) + m = re.match("^\\s*Resolution\\s*:\\s*(\\S+)", line) if m: resolutions.append(m.group(1)) return False - m = re.match("^\s*Status\s*:\s*(.+)", line) + m = re.match("^\\s*Status\\s*:\\s*(.+)", line) if m: statuses.append(m.group(1)) return False - m = re.match("^\s*(\S+)\s*@\s*(\d+)", line) + m = re.match("^\\s*(\\S+)\\s*@\\s*(\\d+)", line) if m: status = m.group(1) changed_attachments[int(m.group(2))] = status return False - m = re.match("^\s*Patch-complexity\s*:\s*(.+)", line) + m = re.match("^\\s*Patch-complexity\\s*:\\s*(.+)", line) if m: patch_complexities.append(m.group(1)) return False - m = re.match("^\s*Depends\s*:\s*([Bb][Uu][Gg])?\s*(\d+)", line) + m = re.match("^\\s*Depends\\s*:\\s*([Bb][Uu][Gg])?\\s*(\\d+)", line) if m: depends.append(m.group(2)) return False -- cgit