Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2893101ybt; Mon, 22 Jun 2020 09:33:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFj8dmIpNZ64ekYcdIynsYkRZLYY+ghZDW2G7WMm30jYCPBTiFBtZwTj8P4HM46TT9RxQe X-Received: by 2002:aa7:c986:: with SMTP id c6mr18218904edt.335.1592843621202; Mon, 22 Jun 2020 09:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592843621; cv=none; d=google.com; s=arc-20160816; b=m54ZDWE3AQvEaJ+bBqeQXLLRqf3IycjseR7GAd22r0OXQfaC1LZmnKsqPNLe7xZGS/ irlK33eUkh/ws1FZxDG0eg8LFbnYnqGaO/vWHY/k0pxTCfrdEU25TPtGMet2LNhPB9j3 mgVaVwRnwkqgKab7q80ZFQ5xRU7HmFZFyFw2bNnw/v3yp1GbdYeOJLzH11VSBa4Pwq5d I/svbySoDqIANxjvddTbut3njs2kUYnBpu+5vROJiAB5QtrO9dAtJpdO84k+pytLt+DL PeMhSMdz/nG3th4vNtQkp7m6Y+paOVMuk3cVTlhhQuOhfqx0UTyZOUdezUxSTOLsaQTV +3gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=QmW7SQAYLusEjEP9SNhqtBuyqLM/cmiYwsk5345jD3s=; b=Sy0Q/rb4YYfVushGbDPBINFctivObXXFN7L/3CfFcIcdxW0dSl0xP5WksoHHBxN+k4 NiY6Cfw0II+Z8FM+fgCJcHFVdstqrLPmuQse/dp/gNpXc9X99Qrc75B97Y39iJCj+bjN t1VWB7+920+/jlkoi9ID7RILCAIMxZStJrnVpVSO30UohOQs3D+d47NzXvplKL5GPWnH V5nyDBCwpXE8IErZADgZACpXohpTqYrsUjvLFexn+1lpPqXrdA4KrioVDNbF0C3oovBJ OXfe2FOsSc21POyyylvvhYQBg6idIpUAx7UkxG33EYvsxreHpNLpZOnY5mUaev+hpv3f OytA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uS9RmRKK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lb19si9009163ejb.295.2020.06.22.09.33.17; Mon, 22 Jun 2020 09:33:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uS9RmRKK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729603AbgFVQba (ORCPT + 99 others); Mon, 22 Jun 2020 12:31:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:46870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729456AbgFVQba (ORCPT ); Mon, 22 Jun 2020 12:31:30 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C86592076E; Mon, 22 Jun 2020 16:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592843490; bh=NtdWqKvTd/VNjC32MyidJh32ZtdjWCh87PdbDpZ7sKQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uS9RmRKKg6cbZw423vs5FcQnWsi7YT0RlqRxjPGYrJ1YkpGxdE7hCMPmvue+1UKsv q7FiVl5YXb5KS8sT2YFq+bE8d9vL5H2c0Jea0CajCNxmVEm7WNMndSea2W4sHn/XwT sZRU0R+5yRkdlQLAJoeO4bRi5Gy0gqIDF6jPAdDE= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 3B5A8405FF; Mon, 22 Jun 2020 13:31:27 -0300 (-03) Date: Mon, 22 Jun 2020 13:31:27 -0300 From: Arnaldo Carvalho de Melo To: Andreas Gerstmayr Cc: linux-perf-users@vger.kernel.org, Michael Petlan , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] perf flamegraph: explicitly set utf-8 encoding Message-ID: <20200622163127.GB30611@kernel.org> References: <20200619130745.153113-1-agerstmayr@redhat.com> <20200619153232.203537-1-agerstmayr@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200619153232.203537-1-agerstmayr@redhat.com> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. - Arnaldo > Signed-off-by: Andreas Gerstmayr > --- > > 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 > -- - Arnaldo