Skip to content

Issue decoding byte string to utf-8 due to provided encoding is None #182

@rasjani

Description

@rasjani

Im getting following error when running unittests with IronPython:

2019-01-02T11:45:28.1639634Z 
2019-01-02T11:45:28.1639798Z   File "C:\Users\VssAdministrator\AppData\Roaming\Python\IronPython27\site-packages\xmlrunner\runner.py", line 113, in run
2019-01-02T11:45:28.1640448Z 
2019-01-02T11:45:28.1640700Z   File "C:\Users\VssAdministrator\AppData\Roaming\Python\IronPython27\site-packages\xmlrunner\result.py", line 550, in generate_reports
2019-01-02T11:45:28.1640941Z 
2019-01-02T11:45:28.1641087Z   File "C:\Users\VssAdministrator\AppData\Roaming\Python\IronPython27\site-packages\xmlrunner\result.py", line 469, in _createCDATAsections
2019-01-02T11:45:28.1641692Z 
2019-01-02T11:45:28.1641966Z   File "C:\Users\VssAdministrator\AppData\Roaming\Python\IronPython27\site-packages\xmlrunner\result.py", line 442, in _report_testsuite
2019-01-02T11:45:28.1643263Z 
2019-01-02T11:45:28.1643532Z   File "C:\Users\VssAdministrator\AppData\Roaming\Python\IronPython27\site-packages\xmlrunner\result.py", line 72, in safe_unicode
2019-01-02T11:45:28.1644257Z 
2019-01-02T11:45:28.1644437Z   File "C:\Users\VssAdministrator\AppData\Roaming\Python\IronPython27\site-packages\xmlrunner\result.py", line 56, in xml_safe_unicode
2019-01-02T11:45:28.1644550Z 
2019-01-02T11:45:28.1644626Z TypeError: decode() expected string, got 'NoneType'

the issue seems to be that when safe_unicode is called within results.py, encoding is never passed in - and then the default value of None is then passed forward to xml_safe_unicode. On IronPython, this then triggers base.encode() call but encoding is None.

Maybe the quick fix would be to change the default value of encoding in safe_unicode to "utf-8" ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions