lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4a02db6c-3a47-09aa-1534-48926d425633@redhat.com>
Date:   Mon, 22 Jun 2020 19:45:39 +0200
From:   Andreas Gerstmayr <agerstmayr@...hat.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     linux-perf-users@...r.kernel.org,
        Michael Petlan <mpetlan@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] perf flamegraph: explicitly set utf-8 encoding

On 22.06.20 18:31, Arnaldo Carvalho de Melo wrote:
> Em Fri, Jun 19, 2020 at 05:32:31PM +0200, Andreas Gerstmayr escreveu:
>> on some platforms the default encoding is not utf-8,
>> which causes an UnicodeDecodeError when reading the flamegraph template
>> and writing the flamegraph
> 
> Thanks, applied.

Thank you!

Cheers,
Andreas


> 
> - Arnaldo
>   
>> Signed-off-by: Andreas Gerstmayr <agerstmayr@...hat.com>
>> ---
>>
>> changelog v2: also write to stdout with utf-8 encoding
>>
>>   tools/perf/scripts/python/flamegraph.py | 8 +++++---
>>   1 file 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)
>> -- 
>> 2.25.4
>>
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ