On 13.05.2016 00:00, Evgeny Kotkov wrote:
> Stefan Fuhrmann <stefan2_at_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())
>> - 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
> 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.
Received on 2016-05-13 02:54:41 CEST