I added it because without it installation on Fedora 28 was broken. I don't remember
what was the error but probably the content was unicode instead of bytes.
if binary:
self._content = content
else:
if isinstance(content, list) or isinstance(content, tuple):
self._content = '\n'.join([common.toStr(i) for i in content])
if content:
self._content += '\n'
else:
self._content = common.toStr(content)
if not self._content.endswith('\n'):
self._content += '\n'
self._content = self._content.encode("utf-8")
It looks like the binary flag value is wrong, or common.toStr() is encoding
the values to bytes.
The common error in python 2 is:
>>> text = u"\u05d0"
>>> encoded = text.encode("utf-8")
>>> encoded.encode("utf-8")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd7 in position 0: ordinal not in range(128)
But:
>>> text = u"ascii"
>>> encoded = text.encode("utf-8")
>>> encoded.encode("utf-8")
'ascii'
Which seems to be the case in [2].
So if common.toStr() is encoding the values, there is no need to encode the values
again in line 151.
to read utf-8 data.