setup: convert setupversion to unicode
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 11 Mar 2017 17:14:02 -0800
changeset 31316 70bc35df3e54
parent 31315 78ac7061f840
child 31317 0bd32d7c9002
setup: convert setupversion to unicode Something deep in the bowels of distutils expects "version" passed to setup() to be a str/unicode. So, convert the type. This still works on Python 2 because the string is ascii and an implicit coercion back to str/bytes should work without issue. If it does cause problems, we can always make the unicode conversion dependent on running Python 3. This change makes `python3.5 setup.py install` work.
setup.py
--- a/setup.py	Wed Jan 14 01:15:26 2015 +0100
+++ b/setup.py	Sat Mar 11 17:14:02 2017 -0800
@@ -661,7 +661,14 @@
             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: