Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2942858ybt; Mon, 22 Jun 2020 10:49:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDRrZ8Lo048rkwJgIiPlB3OsHvr1j8xKTzcOqx665qNNa+EhtKrmNqol2DhkJaIKk8/CQy X-Received: by 2002:a05:6402:897:: with SMTP id e23mr18339595edy.217.1592848154987; Mon, 22 Jun 2020 10:49:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592848154; cv=none; d=google.com; s=arc-20160816; b=QBSRrSystqIxVSTxaeXWP03WVBGEnc7aRigQF1d6UBM63wMkp49ybqn8A/xN8mQyqK FosGxE+y50id1LVsebaWKVdFyJFOhx1A7ZAcWgamehVYTIJAnAOPfXNp+pqUzwE2wk/l rVZHb0mfRX+WoHxhUVePF1gt7iwMnfhmYPfNv1q0qE01tkOapQnsQUrtWiFbDVFc+lGp +m2dew/zYdxukWDdICwwMclkBGFQtSycpgs5RStqWy3k8QaCODlL296gEZnWSzZ5gclh OfBYSuQC6LeUZVi6YJmP7+D0UFMvV9WB6Zm83eShK5lRt1XX73ewV7b16xNNvTjEx79t PC5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=iN1S6As8dV2WMckXA3iY7pg1t1BvSi4m/4p8lQdBlfU=; b=hvKZhYbbbV0fbxUeUg1W+h1dtJvpctPaY918ngppujaCrMThqX0FLrzzN2R+/cLxgw miIXQLRKlyRZm87rayCKkRuJ8RWgtyvMI8MUhpK883ZlSjNefNqJJum8HGYpclS6RX+m 0d865t0H9R00b86mXKNI6H/pnV2ho2DEESirF6f3bbQGUCdLJ9Fs1zm2x465YbF3uoL5 1YfZzucP3BgLcRvNBj4qakSYTugo8kXpG2osmaFP1T39ZTYkK8u1iHxCIKZ81DWIc04T yFjJCTUNpV4eLg1EaBXIZBlk43zlCuFxOywpcGuILwrVATtCw07x7urBwjN/zzgaGCbZ krCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NiC0d1z7; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gh6si9385442ejb.689.2020.06.22.10.48.51; Mon, 22 Jun 2020 10:49:14 -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=@redhat.com header.s=mimecast20190719 header.b=NiC0d1z7; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730046AbgFVRpt (ORCPT + 99 others); Mon, 22 Jun 2020 13:45:49 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:22583 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729605AbgFVRps (ORCPT ); Mon, 22 Jun 2020 13:45:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592847946; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iN1S6As8dV2WMckXA3iY7pg1t1BvSi4m/4p8lQdBlfU=; b=NiC0d1z7Qwno4ZT6EGSRmk4lgTiQiYS97klbPUB70WmtM4AIOVR7iwQUlEUkdU4PoIIDA9 7oVinS2VnOFw/xHv5Dkr/klG6CueukR4G5eOKg2imYKReL+VDcPtC43fw0fR/HvNL+clEE oPeo+k2FR8DYEM3XiOwmM49hZmiJdoA= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-406-4S_ZYQxiOrC3rKS9_RgZEg-1; Mon, 22 Jun 2020 13:45:44 -0400 X-MC-Unique: 4S_ZYQxiOrC3rKS9_RgZEg-1 Received: by mail-ed1-f69.google.com with SMTP id dh12so8389197edb.9 for ; Mon, 22 Jun 2020 10:45:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=iN1S6As8dV2WMckXA3iY7pg1t1BvSi4m/4p8lQdBlfU=; b=INgMuwrs5/BymtcTkLR0fTPEnyfMVQvUEXTsznrkoMvgrBS5v9knRH9xFZWVwW/R84 Hl42BaHDN1ntslISsucXIgoLtdymO7xLc+ILp95RMQI13V1U0FJjQoRkzpeZGs6Fetrv wJXEW/Ump7K7UvgyyLdQ+om65/sUNWhTd/q+HrqbvsDWfOOVsAjoXmLlEbvZMosKzT5O RgD6iV6mSftuZPbeyVKsrgHnYTUQwPX+MakfbDBwjorDM+6NKIuZSzZ9vl9qnEmXla6N 0mlXZtDVV5WVRApusHVrcO5cYrLFSeXTJtfEcvLFxYxeRoFpfjrBXx1CyX7rfh/n/TPg algg== X-Gm-Message-State: AOAM531NYFv2RwZ26R10lRbFYKAyB2pI9OOlUoD+ndHFPfGnnGJYq6b5 SQk8o7YnjIt0xPzwq5W2FyheeEo09Y01E68XXtCEIfYdp9kdHhsEFEwoSvv6pIFqynRCr7plNuJ pi7sQbyuSSRo3CgcoU+GYFcTG X-Received: by 2002:a17:906:c155:: with SMTP id dp21mr16033319ejc.92.1592847941681; Mon, 22 Jun 2020 10:45:41 -0700 (PDT) X-Received: by 2002:a17:906:c155:: with SMTP id dp21mr16033292ejc.92.1592847941379; Mon, 22 Jun 2020 10:45:41 -0700 (PDT) Received: from ?IPv6:2a02:8388:7c1:12f0:2a0d:3df8:7645:8915? (2a02-8388-07c1-12f0-2a0d-3df8-7645-8915.cable.dynamic.v6.surfer.at. [2a02:8388:7c1:12f0:2a0d:3df8:7645:8915]) by smtp.gmail.com with ESMTPSA id p9sm6947423ejd.50.2020.06.22.10.45.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jun 2020 10:45:40 -0700 (PDT) Subject: Re: [PATCH v2] perf flamegraph: explicitly set utf-8 encoding To: Arnaldo Carvalho de Melo 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 References: <20200619130745.153113-1-agerstmayr@redhat.com> <20200619153232.203537-1-agerstmayr@redhat.com> <20200622163127.GB30611@kernel.org> From: Andreas Gerstmayr Message-ID: <4a02db6c-3a47-09aa-1534-48926d425633@redhat.com> Date: Mon, 22 Jun 2020 19:45:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200622163127.GB30611@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> --- >> >> 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 >> >