This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Explicitly open file to write with utf-8 encoding in crashlog.py
ClosedPublic

Authored by augusto2112 on Oct 26 2022, 3:03 PM.

Details

Summary

The python "open" function will use the default encoding for the
locale (the result of "locale.getpreferredencoding()"). Explicitly set
the locale to utf-8 when opening the crashlog for writing, as there may
be non-ascii symbols in there (for example, Swift uses "τ" to indicate
generic parameters).

rdar://101402755

Diff Detail

Event Timeline

augusto2112 created this revision.Oct 26 2022, 3:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 26 2022, 3:03 PM
augusto2112 requested review of this revision.Oct 26 2022, 3:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 26 2022, 3:03 PM
rupprecht accepted this revision.Oct 26 2022, 4:26 PM
rupprecht added a subscriber: rupprecht.

Two other places you might need to update as well

lldb/examples/python/crashlog.py
452

Do you need to specify encoding here too?

647

(and here)

This revision is now accepted and ready to land.Oct 26 2022, 4:26 PM
JDevlieghere accepted this revision.Oct 26 2022, 5:11 PM

LGTM with @rupprecht's comments addressed.

Added encoding parameter to all "open" calls

mib accepted this revision.Oct 28 2022, 3:05 PM

LGTM! Thanks Augusto!

This revision was landed with ongoing or failed builds.Oct 28 2022, 3:06 PM
This revision was automatically updated to reflect the committed changes.