In Python 2, Struct.format used to be a str. In Python 3 it is bytes, which is unexpected.
Why do I expect .format to be a string:
- This format is pretty much the same as a "{}-format" - plain text
- according to documentation it is composed of things like characters from a closed set '<.=@hi...', a subset of ASCII,
- it is always called "format string" in the documentation
Why is this a problem:
- If I use a str format in constructor, I expect to get a str format,
- Comparisons are broken:
>>> struct.Struct('x').format == 'x'
False
>>> struct.Struct('x').format[0] == 'x'
False
- doctests are broken
>>> struct.Struct('x').format
'x' # in Python 2
b'x' # in Python 3 |