File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
tools/perf/scripts/python Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 17
17
from __future__ import print_function
18
18
import sys
19
19
import os
20
+ import io
20
21
import argparse
21
22
import json
22
23
@@ -81,7 +82,7 @@ def trace_end(self):
81
82
82
83
if self .args .format == "html" :
83
84
try :
84
- with open (self .args .template ) as f :
85
+ with io . open (self .args .template , encoding = "utf-8" ) as f :
85
86
output_str = f .read ().replace ("/** @flamegraph_json **/" ,
86
87
json_str )
87
88
except IOError as e :
@@ -93,11 +94,12 @@ def trace_end(self):
93
94
output_fn = self .args .output or "stacks.json"
94
95
95
96
if output_fn == "-" :
96
- sys .stdout .write (output_str )
97
+ with io .open (sys .stdout .fileno (), "w" , encoding = "utf-8" , closefd = False ) as out :
98
+ out .write (output_str )
97
99
else :
98
100
print ("dumping data to {}" .format (output_fn ))
99
101
try :
100
- with open (output_fn , "w" ) as out :
102
+ with io . open (output_fn , "w" , encoding = "utf-8 " ) as out :
101
103
out .write (output_str )
102
104
except IOError as e :
103
105
print ("Error writing output file: {}" .format (e ), file = sys .stderr )
You can’t perform that action at this time.
0 commit comments