diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-07-20 09:43:40 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-07-20 09:43:40 +0200 |
commit | c4d41d00552754cc8cdd66a52da9b7c203884d49 (patch) | |
tree | 60be0f3d543ad6d300a033d91dc313bc595cd737 /tools/perf/scripts/python/flamegraph.py | |
parent | fadbfc38dde26d31e901c3c85cf01332cb6a2224 (diff) | |
parent | ba47d845d715a010f7b51f6f89bae32845e6acb7 (diff) | |
download | lwn-c4d41d00552754cc8cdd66a52da9b7c203884d49.tar.gz lwn-c4d41d00552754cc8cdd66a52da9b7c203884d49.zip |
Merge v5.8-rc6 into char-misc-next
We need the char/misc fixes in here as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/perf/scripts/python/flamegraph.py')
-rwxr-xr-x | tools/perf/scripts/python/flamegraph.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/perf/scripts/python/flamegraph.py b/tools/perf/scripts/python/flamegraph.py index 61f3be9add6b..65780013f745 100755 --- a/tools/perf/scripts/python/flamegraph.py +++ b/tools/perf/scripts/python/flamegraph.py @@ -17,6 +17,7 @@ from __future__ import print_function import sys import os +import io import argparse import json @@ -81,7 +82,7 @@ class FlameGraphCLI: if self.args.format == "html": try: - with open(self.args.template) as f: + with io.open(self.args.template, encoding="utf-8") as f: output_str = f.read().replace("/** @flamegraph_json **/", json_str) except IOError as e: @@ -93,11 +94,12 @@ class FlameGraphCLI: output_fn = self.args.output or "stacks.json" if output_fn == "-": - sys.stdout.write(output_str) + with io.open(sys.stdout.fileno(), "w", encoding="utf-8", closefd=False) as out: + out.write(output_str) else: print("dumping data to {}".format(output_fn)) try: - with open(output_fn, "w") as out: + with io.open(output_fn, "w", encoding="utf-8") as out: out.write(output_str) except IOError as e: print("Error writing output file: {}".format(e), file=sys.stderr) |