Skip to content

Commit 0846b0c

Browse files
johnkeepinggitster
authored andcommitted
git-remote-testpy: hash bytes explicitly
Under Python 3 'hasher.update(...)' must take a byte string and not a unicode string. Explicitly encode the argument to this method to hex bytes so that we don't need to worry about failures to encode that might occur if we chose a textual encoding. This changes the directory used by git-remote-testpy for its git mirror of the remote repository, but this tool should not have any serious users as it is used primarily to test the Python remote helper framework. The use of encode() moves the required Python version forward to 2.0. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent cadbf5c commit 0846b0c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

git-remote-testpy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
from git_remote_helpers.git.importer import GitImporter
3232
from git_remote_helpers.git.non_local import NonLocalGit
3333

34-
if sys.hexversion < 0x01050200:
35-
# os.makedirs() is the limiter
36-
sys.stderr.write("git-remote-testgit: requires Python 1.5.2 or later.\n")
34+
if sys.hexversion < 0x02000000:
35+
# string.encode() is the limiter
36+
sys.stderr.write("git-remote-testgit: requires Python 2.0 or later.\n")
3737
sys.exit(1)
3838

3939
def get_repo(alias, url):
@@ -45,7 +45,7 @@ def get_repo(alias, url):
4545
repo.get_head()
4646

4747
hasher = _digest()
48-
hasher.update(repo.path)
48+
hasher.update(repo.path.encode('hex'))
4949
repo.hash = hasher.hexdigest()
5050

5151
repo.get_base_path = lambda base: os.path.join(

0 commit comments

Comments
 (0)