Python UnicodeEncodeError in the unittest runner during uicheck on Windows

Stephan Bergmann sbergman at redhat.com
Wed Apr 15 08:34:49 UTC 2020


On 14/04/2020 09:14, Stephan Bergmann wrote:
> On 09/04/2020 17:21, Miklos Vajna wrote:
>> One option would be to tweak test_main.py to default to UTF-8, like
>> Linux does. You could try something like this:
>>
>> if sys.platform.startswith("win"):
>>      import _locale
>>      _locale._getdefaultlocale = (lambda *args: ['en_US', 'utf8'])
> 
> Does not make a difference.  Neither if I put this at the top of 
> uitest/test_main.py after all the imports, nor if I put it at the top of 
> the "if __name == '__main__':" block.

For the record, I locally got around the issue with a manual patch of

> --- instdir/program/python-core-3.7.7/lib/unittest/runner.py
> +++ instdir/program/python-core-3.7.7/lib/unittest/runner.py
> @@ -114,7 +114,7 @@
>              self.stream.writeln(self.separator1)
>              self.stream.writeln("%s: %s" % (flavour,self.getDescription(test)))
>              self.stream.writeln(self.separator2)
> -            self.stream.writeln("%s" % err)
> +            self.stream.writeln("%s" % err.encode('unicode_escape'))
>  
>  
>  class TextTestRunner(object):

for the moment (but which makes the UITest failure output hard to read, 
of course).



More information about the LibreOffice mailing list