This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Read files as bytestrings to fix py3 encoding issues
ClosedPublic

Authored by mgorny on Jun 14 2019, 10:25 AM.

Details

Summary

Use binary mode to read test files in libcxx LibcxxTestFormat class.
This ensures that tests are read correctly independently of encoding,
and therefore fixes UnicodeDecodeError when file is opened in Python 3
that defaults to pure ASCII encoding.

Technically this could be also fixed via conditionally appending
encoding argument when opening the file in Python 3. However, since
the code in question only searches for fixed ASCII substrings reading
it in binary mode is simpler and more universal.

Diff Detail

Repository
rL LLVM

Event Timeline

mgorny created this revision.Jun 14 2019, 10:25 AM

Is this backwards compatible as well?

Is this backwards compatible as well?

With Python 2.7? Yes, it has forward compatibility with py3 bytestrings. I'll do one more test run to confirm.

…and confirmed.

EricWF accepted this revision.Jun 23 2019, 9:02 AM

Thanks. Sorry for the delay.

LGTM.

This revision is now accepted and ready to land.Jun 23 2019, 9:02 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 24 2019, 2:41 AM