Submitter | Gregory Szorc |
---|---|
Date | March 12, 2017, 1:14 a.m. |
Message ID | <7aed668a0af18397d6d4.1489281254@gps-mbp.local> |
Download | mbox | patch |
Permalink | /patch/19128/ |
State | Accepted |
Headers | show |
Comments
On Sat, 11 Mar 2017 17:14:14 -0800, Gregory Szorc wrote: > # HG changeset patch > # User Gregory Szorc <gregory.szorc@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.
Patch
diff --git a/setup.py b/setup.py --- 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') + extra = {} if py2exeloaded: extra['console'] = [