From 2924aab5a5308da30e2a801dbb47a976a95e4bee 2014-04-16 21:31:22 From: MinRK Date: 2014-04-16 21:31:22 Subject: [PATCH] Backport PR #5505: Make backport_pr work on Python 3 This turned out to be pretty easy. --- diff --git a/tools/backport_pr.py b/tools/backport_pr.py index 303c8f5..cf59cda 100755 --- a/tools/backport_pr.py +++ b/tools/backport_pr.py @@ -26,7 +26,10 @@ import re import sys from subprocess import Popen, PIPE, check_call, check_output -from urllib import urlopen +try: + from urllib.request import urlopen +except: + from urllib import urlopen from gh_api import ( get_issues_list, @@ -45,8 +48,8 @@ def find_rejects(root='.'): def get_current_branch(): branches = check_output(['git', 'branch']) for branch in branches.splitlines(): - if branch.startswith('*'): - return branch[1:].strip() + if branch.startswith(b'*'): + return branch[1:].strip().decode('utf-8') def backport_pr(branch, num, project='ipython/ipython'): current_branch = get_current_branch()