Re: [RFC/PATCH 2/8 v2] git_remote_helpers: fix input when running under Python 3
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 15, 2013, 20:51 UTC
- Message-ID
- <7vbocq2mri.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20130115194809.GU4574@serenity.lan>
John Keeping <john@keeping.me.uk> writes:
Show 13 quoted lines
> Although 2to3 will fix most issues in Python 2 code to make it run under > Python 3, it does not handle the new strict separation between byte > strings and unicode strings. There is one instance in > git_remote_helpers where we are caught by this, which is when reading > refs from "git for-each-ref". > > While we could fix this by explicitly handling refs as byte strings, > this is merely punting the problem to users of the library since the > same problem will be encountered as soon you want to display the ref > name to a user. > > Instead of doing this, explicit decode the incoming byte string into a > unicode string.
That really feels wrong. Displaying is a separate issue and it is the _right_ thing to punt the problem at the lower-level machinery level.
> Following the lead of pygit2 (the Python bindings for > libgit2 - see [1] and [2]),...
I do not think other people getting it wrong is not an excuse to repeat the same mistake.
Is it really so cumbersome to handle byte strings as byte strings in Python?