Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp464772ybt; Fri, 19 Jun 2020 06:11:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyprwZr2diKuxsB1ghyAGKRD9uyP1dF1SCz/19lusB8s4uDwSGYWt+vSw6EWa6vZ+9BfooO X-Received: by 2002:a17:906:ae85:: with SMTP id md5mr3573532ejb.213.1592572303184; Fri, 19 Jun 2020 06:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592572303; cv=none; d=google.com; s=arc-20160816; b=lneJ78CIWJsgzKzS8DS7xXwyYMXFcDBuC2q0YCRN56fA2JonSnUiQZiuPhPPN0Xmnw a9m+uR1uH5jZBP1nJbkBFwWoxI/Y8VfpviuNO+TV90IqAeQqZKqt9AO66+7yhUCOQFRp MN0nUHjyAuoaADO31wLPXhpvGtcRWprKL0ZbbUvlIHs63bA+2aIYLgQPVL/EciOatih1 Lf88ShmK+aUFTUAFp+WerD20/abSutyLjXbqF/sjzp3GAqriONZhIsth00zcnBBBSUAI IfLWZTgM4JqDaY4VSjPxS/Vyv5bkuQdJFrKWMyPWl9iGM4ccE31YZ49x5dZuBQj24YKm EXkA== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=OK11zaapoxWJXtILVuIHMvOvKkMZ2TEh815CSjabwLM=; b=Aa7R5SR+ZWh+cguCtW6Eyln87BObODzpjZNQLoYN2QypIlii3eS2Fu7P7+wKPQfKXE 2S5bs8xdTS0LHftBmdGefnwu0xFT0czREDWXA8N6Fn77+w2blp9v7LsrPhC3ECaEcSue +FYeMxD+ro7OWppgjEaZwY4VN7PcMjRIGKmu739xnbh1dB4I0xP5L2dacf675mA9uj70 gDcBJYqCEjP9bda5AQhWvfyWKRqPUw8IwQuxzwDsVXPMzP7L2yEn4gNnBVNQsuBpt6VD exSnOS1JdwUCTh6Y4/z1f4V31RMwXvjMNGQ/Kd2O5hHU8TtHMoW+oGHL5H6L9AltpzZR Xd2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AMFgCmWR; 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 a22si3676284ejr.529.2020.06.19.06.11.19; Fri, 19 Jun 2020 06:11:43 -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=AMFgCmWR; 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 S1729134AbgFSNJH (ORCPT + 99 others); Fri, 19 Jun 2020 09:09:07 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:48536 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727074AbgFSNJC (ORCPT ); Fri, 19 Jun 2020 09:09:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592572141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=OK11zaapoxWJXtILVuIHMvOvKkMZ2TEh815CSjabwLM=; b=AMFgCmWRDRAvK1RYZWKW9i5Fnli/60QfcTXo0QfD12Vwk54fw7wGBD22cwhiOMv6LWwJG9 +3jNpZ1WjwH/uJLb2H0t8Sj/kirSI3108biujgiHEP5CJf/X2G4JPOhTKYk8cE8RtHPcbg Ao3SDcJ1QEYthkI4yFgN5dK/ScHHJQ8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-PA03q-gaMLqEu7SXLAaFYA-1; Fri, 19 Jun 2020 09:08:58 -0400 X-MC-Unique: PA03q-gaMLqEu7SXLAaFYA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 16C428057B0; Fri, 19 Jun 2020 13:08:37 +0000 (UTC) Received: from agerstmayr-thinkpad.redhat.com (unknown [10.40.196.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9502871667; Fri, 19 Jun 2020 13:08:34 +0000 (UTC) From: Andreas Gerstmayr To: linux-perf-users@vger.kernel.org Cc: Michael Petlan , Andreas Gerstmayr , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org Subject: [PATCH] perf flamegraph: explicitly set utf-8 encoding Date: Fri, 19 Jun 2020 15:07:43 +0200 Message-Id: <20200619130745.153113-1-agerstmayr@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org on some platforms the default encoding is not utf-8, which causes an UnicodeDecodeError when reading the flamegraph template Signed-off-by: Andreas Gerstmayr --- Tested with Python 2.7 and 3. tools/perf/scripts/python/flamegraph.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/perf/scripts/python/flamegraph.py b/tools/perf/scripts/python/flamegraph.py index 61f3be9add6b..8979db910a8f 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: @@ -97,7 +98,7 @@ class FlameGraphCLI: 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