From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 54E9AA00B8 for ; Sun, 27 Oct 2019 21:32:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1A84A1BEFF; Sun, 27 Oct 2019 21:32:46 +0100 (CET) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by dpdk.org (Postfix) with ESMTP id 868F11BEFF; Sun, 27 Oct 2019 21:32:44 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 4011C5B1; Sun, 27 Oct 2019 16:32:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 27 Oct 2019 16:32:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=mesmtp; bh=uQ2Hi42pje4ob5liXt20gD/V6SHzcbTbXzGEhfJP3nQ=; b=HdHzlUucUc5i MtPNlsgES9t3lqruzGK2aTflvMZA9kHoviXfkBaNR/MfA3s/Zn8m+Gj1SDN89Vxs mEUyzEeaCYAKOUiF2hxqxDFXpLArvKjcgLyDIv3xYjgQ0Ec4w1H+XhjzAIprrk5y gA37GF6L65KU9anOQafza2QpcFCyFsY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=uQ2Hi42pje4ob5liXt20gD/V6SHzcbTbXzGEhfJP3 nQ=; b=SItiMYF8Nr0cjQPrw6iefNkzxxfKejfKMoueovVIHxSbBE6TCIovEktmB pKPIbTy88Cr6T1OThE6Lo9eHH2b5kZEEyP++thQp4HRYv6/1+mkrKjHxW4wJ/j/6 gOkNVCkt61sG2peWypik1kYH0lN4k7rbCSLSUiTGqpCzZBbXr7WKs+r8+CpNRXMh Cc7ZfjF9BJB5+MupqgTOWsOzjq2zjgszcFN3dfDkjD3vVXUr8bOVFKlxH0F69Pwy AxMlmQfvc6cbpiO5ptgFqq/xiYXWzsqMgHn7BezItgKUnjmHML2amcWmarzxRbri A14xWm6oYTUNqKbk+8j/KXAv8UYRg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrleejgddugeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfgjfhgggfgtsehtufertddttddvnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecuff homhgrihhnpehgihhthhhusgdrtghomhenucfkphepjeejrddufeegrddvtdefrddukeeg necurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvg htnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id B235180064; Sun, 27 Oct 2019 16:32:40 -0400 (EDT) From: Thomas Monjalon To: Robin Jarry Cc: dev@dpdk.org, Neil Horman , John McNamara , stable@dpdk.org, Olivier Matz Date: Sun, 27 Oct 2019 21:32:39 +0100 Message-ID: <4227183.zDIGceruMn@xps> In-Reply-To: <20191015123918.10775-1-robin.jarry@6wind.com> References: <20190910071135.27546-1-robin.jarry@6wind.com> <20191015123918.10775-1-robin.jarry@6wind.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH v3] usertools: fix py3 support with pyelftools>=0.24 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 15/10/2019 14:39, Robin Jarry: > Running dpdk-pmdinfo.py on Ubuntu 18.04 (bionic) with python 3 and > pyelftools installed produces no output but no error is reported > neither: > > ~$ python3 usertools/dpdk-pmdinfo.py -r build/app/testpmd > ~$ echo $? > 0 > > While with python 2, it works: > > ~# python2 usertools/dpdk-pmdinfo.py -r build/app/testpmd > {"pci_ids": [], "name": "dpio"} > {"pci_ids": [], "name": "dpbp"} > {"pci_ids": [], "name": "dpaa2_qdma"} > ..... > > On Ubuntu 18.04, pyelftools is version 0.24. The change log of > pyelftools v0.24 says: > > - Symbol/section names are strings internally now, not bytestrings > (this may affect API usage in Python 3) (#76). > > We cannot guess which version of pyelftools is actually being used. The > elftools.__version__ symbol is not consistent with each distro's package > version. For example, on Ubuntu 16.04 (xenial), the .deb package version > is '0.23-2' but elftools.__version__ contains '0.25'. This is certainly > due to partial backports. > > To have a more consistent behaviour of this script across all versions > of python, add the unicode_literals future import so that literal > strings are now always "unicode". > > Add 2 utility functions to force a string into bytes or bytes into an > unicode string. > > Force pyelftools return values to unicode strings (will do nothing with > recent version of pyelftools). > > If elffile.get_section_by_name returns None with a unicode section name, > try with the same one encoded as bytes. > > Also, replace all open() calls by io.open() which behaves like the > builtin open in python 3. The only non-binary opened file is > /usr/share/hwdata/pci.ids which is UTF-8 encoded text. Explicitly > specify that encoding. > > Link: https://github.com/eliben/pyelftools/blob/v0.24/CHANGES#L7 > Link: https://github.com/eliben/pyelftools/commit/108eaea9e75a8b5a > Fixes: 54ca545dce4b ("make python scripts python2/3 compliant") > Cc: John McNamara > Cc: stable@dpdk.org > Signed-off-by: Robin Jarry > Reviewed-by: Olivier Matz I am really scary by all of this, but I trust you to fix it properly. Applied, thanks