Re: [PATCH v3 6/8] git-remote-testpy: hash bytes explicitly
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 26, 2013, 21:44 UTC
- Message-ID
- <7vwquzzkiw.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20130126175158.GK7498@serenity.lan>
John Keeping <john@keeping.me.uk> writes:
Show 9 quoted lines
> Junio, can you replace the queued 0846b0c (git-remote-testpy: hash bytes > explicitly) with this? > > I hadn't realised that the "hex" encoding we chose before is a "bytes to > bytes" encoding so it just fails with an error on Python 3 in the same > way as the original code. > > Since we want to convert a Unicode string to bytes I think UTF-8 really > is the best option here.
Ahh. I think it is already in "next", so this needs to be turned into an incremental to flip 'hex' to 'utf-8', with the justification being these five lines above.
Thanks for catching.
Show 30 quoted lines
>
> git-remote-testpy.py | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/git-remote-testpy.py b/git-remote-testpy.py
> index d94a66a..f8dc196 100644
> --- a/git-remote-testpy.py
> +++ b/git-remote-testpy.py
> @@ -31,9 +31,9 @@ from git_remote_helpers.git.exporter import GitExporter
> from git_remote_helpers.git.importer import GitImporter
> from git_remote_helpers.git.non_local import NonLocalGit
>
> -if sys.hexversion < 0x01050200:
> - # os.makedirs() is the limiter
> - sys.stderr.write("git-remote-testgit: requires Python 1.5.2 or later.\n")
> +if sys.hexversion < 0x02000000:
> + # string.encode() is the limiter
> + sys.stderr.write("git-remote-testgit: requires Python 2.0 or later.\n")
> sys.exit(1)
>
> def get_repo(alias, url):
> @@ -45,7 +45,7 @@ def get_repo(alias, url):
> repo.get_head()
>
> hasher = _digest()
> - hasher.update(repo.path)
> + hasher.update(repo.path.encode('utf-8'))
> repo.hash = hasher.hexdigest()
>
> repo.get_base_path = lambda base: os.path.join(