[PATCH] D68223: [LNT] Python 3 support: fix convert to JSON
Thomas Preud'homme via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 3 08:17:55 PDT 2019
This revision was automatically updated to reflect the committed changes.
thopre marked an inline comment as done.
Closed by commit rL373615: [LNT] Python 3 support: fix convert to JSON (authored by thopre, committed by ).
Herald added a project: LLVM.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68223/new/
https://reviews.llvm.org/D68223
Files:
lnt/trunk/lnt/formats/JSONFormat.py
Index: lnt/trunk/lnt/formats/JSONFormat.py
===================================================================
--- lnt/trunk/lnt/formats/JSONFormat.py
+++ lnt/trunk/lnt/formats/JSONFormat.py
@@ -19,9 +19,17 @@
return json.load(path_or_file)
+def _dump_format(obj, fp):
+ # The json module produces str objects but fp is opened in binary mode
+ # (since Plistlib only dump to binary mode files) so we first dump into
+ # a string a convert to UTF-8 before outputing.
+ json_str = json.dumps(obj)
+ fp.write(json_str.encode())
+
+
format = {
'name': 'json',
'predicate': _matches_format,
'read': _load_format,
- 'write': json.dump,
+ 'write': _dump_format,
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68223.223028.patch
Type: text/x-patch
Size: 704 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191003/173808f6/attachment.bin>
More information about the llvm-commits
mailing list