[Lldb-commits] [PATCH] D136798: [lldb] Explicitly open file to write with utf-8 encoding in crashlog.py

Augusto Noronha via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 26 15:03:34 PDT 2022


augusto2112 created this revision.
augusto2112 added reviewers: mib, JDevlieghere, jingham.
Herald added a project: All.
augusto2112 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136798

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===================================================================
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -865,7 +865,7 @@
         result.PutCString(
             "error: invalid arguments, a single output file is the only valid argument")
         return
-    out_file = open(args[0], 'w')
+    out_file = open(args[0], 'w', encoding='utf-8')
     if not out_file:
         result.PutCString(
             "error: failed to open file '%s' for writing...",


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136798.470949.patch
Type: text/x-patch
Size: 537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221026/da9ab812/attachment.bin>


More information about the lldb-commits mailing list