On 13.05.2016 02:54, Branko Čibej wrote:
On 13.05.2016 00:00, Evgeny Kotkov wrote:
Stefan Fuhrmann <stef...@apache.org> writes:
TestHarness._run_test): The log is binary data, so write byte strings
to it.
[...]
if self.opts.list_tests:
- log.write('LISTING: %s\n' % progbase)
+ log.write(('LISTING: %s\n' % progbase).encode())
else:
- log.write('START: %s\n' % progbase)
+ log.write(('START: %s\n' % progbase).encode())
Hm, do these log.write() calls always expect bytes? I see that `log'
can be set to two different values, as per run_tests.py:880:
if self.log:
log = self.log
else:
log = sys.stdout # with --log-to-stdout
And sys.stdout.write() works with strings, so this probably won't work
if tests are run with the --log-to-stdout option.
I was thinking about that, yes. Instead of opening log files with
open(), then encoding everything written to them ... I believe it would
be better to open the files with codecs.open(). This should work for
expected results and such, too, I think, and would certainly make the
streams work consistently between Python 2 and Python 3.
We could use codecs.open("latin-1") to allow for more
or less no text filtering. It might even work for our log
copying and filtering code. But we will use the ability to
diagnose newline mismatches in the error descriptions.
-- Stefan^2.