So I'm working on the "style" branch, to make it possible to configure the style of version string that you want, and I've run into a question that I need help with. Should the version string exposed to your program, on python2, be bytes or unicode? How about on python3?
In earlier versions, I think we've been doing bytes on py2 and str (ie unicode) on py3. In a sense, these are the "normal" printable-string types on those platforms. Versions are frequently printed in response to a CLI command, sometimes stored in files (debug logs, sometimes as a compatibility marker for serialized data), and occasionally sent over the network (again for compatibility).
Two things are affecting my viewpoint:
- the new branch uses JSON to store version information for the "from-file" case (where you've run
setup.py build and it writes pre-rendered version data into the _version.py), and python's modern JSON module likes to return unicode keys and values on py2, even if you wrote bytes in the first place.
- git tags can nominally be unicode, directory-name prefixes could nominally be unicode, and we derive versions from both of those. So maybe versions should be unicode too.
The switch might require applications to explicitly .encode() the version before sending it to something that really wants bytes, like a logfile or (maybe even) stdout.
Thoughts?
So I'm working on the "style" branch, to make it possible to configure the style of version string that you want, and I've run into a question that I need help with. Should the version string exposed to your program, on python2, be bytes or unicode? How about on python3?
In earlier versions, I think we've been doing bytes on py2 and str (ie unicode) on py3. In a sense, these are the "normal" printable-string types on those platforms. Versions are frequently printed in response to a CLI command, sometimes stored in files (debug logs, sometimes as a compatibility marker for serialized data), and occasionally sent over the network (again for compatibility).
Two things are affecting my viewpoint:
setup.py buildand it writes pre-rendered version data into the_version.py), and python's modern JSON module likes to return unicode keys and values on py2, even if you wrote bytes in the first place.The switch might require applications to explicitly
.encode()the version before sending it to something that really wants bytes, like a logfile or (maybe even) stdout.Thoughts?