[PATCH V2] setup: convert setupversion to unicode

Yuya Nishihara yuya at tcha.org
Sun Mar 12 11:44:48 EDT 2017


On Sat, 11 Mar 2017 17:14:14 -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1489281242 28800
> #      Sat Mar 11 17:14:02 2017 -0800
> # Node ID 7aed668a0af18397d6d413b625d019fd5333d081
> # Parent  718a57e95a897f4ac407ae3733a7d41e87354acb
> setup: convert setupversion to unicode

Queued, thanks.

> --- a/setup.py
> +++ b/setup.py
> @@ -660,9 +660,16 @@ for root in ('templates',):
>              f = os.path.join(curdir, f)
>              packagedata['mercurial'].append(f)
>  
>  datafiles = []
> -setupversion = version
> +
> +# distutils expects version to be str/unicode. Converting it to
> +# unicode on Python 2 still works because it won't contain any
> +# non-ascii bytes and will be implicitly converted back to bytes
> +# when operated on.
> +assert isinstance(version, bytes)
> +setupversion = version.decode('ascii')

version isn't always bytes type depending whether it is a literal defined in
setup.py or not, but this patch wouldn't make things worse on Python 2.


More information about the Mercurial-devel mailing list