Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4493937ybb; Tue, 14 Apr 2020 08:22:17 -0700 (PDT) X-Google-Smtp-Source: APiQypLJlj+DW/WnnjKf5oJtP2fn+Ag7JtIg1R2GQW0ockAnygrf5x7mmJTjrnJ/+CIDbtY1/2O0 X-Received: by 2002:aa7:df8c:: with SMTP id b12mr21557187edy.22.1586877736998; Tue, 14 Apr 2020 08:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586877736; cv=none; d=google.com; s=arc-20160816; b=ZMd5Lu9LLOqoJ0DiaRik4VFoRiJ2QAlNbnGKlul1x7anLAoCJctM+oqjHPmWTiWBPB /i7i/D7ZyfghPfOYhUYGqCx3P9YUXn7FOf/byrkjx7cnZfPDjenoPacpzmBpKmi82tPj BICW8iFch89WMrWR8C1SveIWxXDO9J7LDVv2Zbns+vy7s5CQgMfsytNBSnCOEhLmlwdn JQX1TYNiVw4XTrPFXSH3a0L4ppzSB6EX4wA3X03NuhWmd8dwQmoFUzXu/JlTDd2VpPnG XVOQ3e4UDrDRlc1gMdYUT+LhqPqWdoK+M2mCMGbRyIrnvOKo81oalpKM5IeK790+r6eY QgXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=2hf2r+2wVOWBvmSoLn7/fDnDty1h5K4Nf4IQt6b/VXs=; b=JXqHdN6CZ3vA5YWPePFep8CbXjilOrPK+1ObZ/Kpqjaj3C4rsEhRxXBiXvII1p8Hdq Bw9cSvY88Ce/+bxyKxGBNka5kLXsNZweW0jTulNXXxZAwCNMoSDAUXdKj5b+mKtvu8PW BhO0lOi4dBiQhBxrU/IQE6t2ixThbD4HTn5sCNIW3PgSTXM+Y90UEzigtVckptf915Sy AvJ9V9/GXJTzJrbrz+wC3TuwblbOrys014Hm6xvJpUadlThLv9C1Iw/sd0DOv7dr//59 yJkdA04z9srz0dJ6MsbQZLqLXW4MmdjWpLSKmT0/de2oNhkVeUHqZFexV6fg7oFFZvjx H0Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@easyb-ch.20150623.gappssmtp.com header.s=20150623 header.b=oZuCdEKr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id la2si8883914ejb.371.2020.04.14.08.21.52; Tue, 14 Apr 2020 08:22:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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=@easyb-ch.20150623.gappssmtp.com header.s=20150623 header.b=oZuCdEKr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390841AbgDNLOU (ORCPT + 99 others); Tue, 14 Apr 2020 07:14:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728734AbgDNLOP (ORCPT ); Tue, 14 Apr 2020 07:14:15 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8A84C061A0C for ; Tue, 14 Apr 2020 04:14:14 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id h2so12519611wmb.4 for ; Tue, 14 Apr 2020 04:14:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=easyb-ch.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=2hf2r+2wVOWBvmSoLn7/fDnDty1h5K4Nf4IQt6b/VXs=; b=oZuCdEKrLiXXACXu02t5Ord1KePOALbWLPWSCdt0MaGN6o60hFWt7+Anj+VqW6mz3c 5RAqS9SQUBW6sd+kaDpyTWwJkBHxsG2+xT2IOhXMKe28847HtBZYcdqvyGaCTbJssfia vl9WPxEtjLO7iuAJ3CvgFOwOY/661H8LqVY4pgw3rQDLwmR2yHKihrr8fl6BuTYtQhx/ 3lMKPdBP98AIeeHTF7XhtKIk0WEjSC9yoShfOsW8mexfyOPRwusOTu1CC0nj1IXQgc3G lFG2LH7CVDCULB7DhsrZhrx6r92JcqEhS7dVGtcABZOwRHYuSsnngd0/PVs51NrmMJMI xipQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=2hf2r+2wVOWBvmSoLn7/fDnDty1h5K4Nf4IQt6b/VXs=; b=Nj8QdYn5/pFTIrkmq8vWmUrW/K/i37nX9gm5Yt+Qvohv9kamJV5DH43xNmruzc4TG7 LRTB3+w/dK73dZ853zMSbjIqdunbZgnQYV2xBv/h1V+y7qltUcLxMVdGOgoV6SVBI3gX viSIQ2gXJLuxnBYkoGgFDttAwl5aGngk2vli3uJRbvy3jeqkhRsxO5K11rn/nn0xG1yQ omzw+RExM0FTymzvZAKy9Kt9BRljuXtLPEjCo75IezjUSTxsuZlY8N+iCcMg8BSwB6sB Uoa10R01+uPUfOdveMWX91yrKTWAjHL8Gwl9en1D9f+Wpk87DaH96OaBKmiI+J/oeqv9 aqxA== X-Gm-Message-State: AGi0PubelERuAzzld5vmR7eGUvVXi/ZsOosKpOxu+Pj9/ESCfii/k+D3 3S5E55Eu+IXwzESf43UmCor8oQ== X-Received: by 2002:a1c:1b88:: with SMTP id b130mr22771164wmb.75.1586862853356; Tue, 14 Apr 2020 04:14:13 -0700 (PDT) Received: from [10.0.0.131] (adsl-84-227-160-19.adslplus.ch. [84.227.160.19]) by smtp.gmail.com with ESMTPSA id p10sm18165006wrm.6.2020.04.14.04.14.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Apr 2020 04:14:12 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.5\)) Subject: Re: [PATCH] selftests/tpm2: Change exception handling to be Python 3 compatible From: Ezra Buehler In-Reply-To: <20200414073806.GE8403@linux.intel.com> Date: Tue, 14 Apr 2020 13:14:11 +0200 Cc: Shuah Khan , linux-kselftest@vger.kernel.org, linux-integrity@vger.kernel.org, Tadeusz Struk , open list Content-Transfer-Encoding: quoted-printable Message-Id: <3DDD1D36-9FCC-480A-978F-3BD08283DA03@easyb.ch> References: <20200412143656.72955-1-jarkko.sakkinen@linux.intel.com> <1FE03B4F-C42C-4B5F-A4B5-8169705911FA@easyb.ch> <20200412170719.GA324408@linux.intel.com> <531D50E8-E8FC-402E-9226-6000E8B6E960@easyb.ch> <20200413180440.GA10917@linux.intel.com> <20200414073806.GE8403@linux.intel.com> To: Jarkko Sakkinen X-Mailer: Apple Mail (2.3445.9.5) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14 Apr 2020, at 09:38, Jarkko Sakkinen = wrote: > OK, I'm aware about the dynamic nature but in this case it is somewhat > counter intuitive since it is part of the exception clause. You'd = except > the Python interpreter to complain. I agree. > So, is Flake8 like the standard to be used? Pretty much, yes. There is also Pylint though. Among other things, they both check for PEP 8 (official) coding style compliance. Cheers, Ezra. > On 14 Apr 2020, at 09:38, Jarkko Sakkinen = wrote: >=20 > On Tue, Apr 14, 2020 at 07:45:33AM +0200, Ezra Buehler wrote: >> Hi Jarkko, >>=20 >> On 13 Apr 2020, at 20:04, Jarkko Sakkinen = wrote: >>>=20 >>> On Mon, Apr 13, 2020 at 07:02:20AM +0200, Ezra Buehler wrote: >>>> Hi Jarkko, >>>>=20 >>>> On 12 Apr 2020, at 19:07, Jarkko Sakkinen = wrote: >>>>>=20 >>>>> On Sun, Apr 12, 2020 at 05:02:27PM +0200, Ezra Buehler wrote: >>>>>> Hi Jarkkon, >>>>>>=20 >>>>>>> On 12 Apr 2020, at 16:36, Jarkko Sakkinen = wrote: >>>>>>> + except ProtocolError(e): >>>>>>=20 >>>>>> Should this not be >>>>>>=20 >>>>>> except ProtocolError as e: >>>>>=20 >>>>> Unless there is a functional difference, does it matter? >>>>>=20 >>>>> /Jarkko >>>>=20 >>>> Well, your patch confuses me a lot. It looks to me like you are = passing >>>> the undefined `e` variable to the constructor. >>>>=20 >>>> When I run flake8 on it I get following error (among others): >>>>=20 >>>> F821 undefined name 'e' >>>=20 >>> I don't know what flake8 is. >>=20 >> https://flake8.pycqa.org/en/latest/ >>=20 >>>> What I suggested is the standard syntax: >>>> https://docs.python.org/3/tutorial/errors.html >>>=20 >>> It passed the Python 3 interpreter. >>=20 >> That is because it is technically valid syntax. >>=20 >>>> Did you test this? You should get an error as soon as an exception >>>> occurs. >>>=20 >>> Yes. Interpreter did not complain. I did not know that the language >>> is broken that way that you have to exercise the code path to get >>> a syntax error. >>=20 >> That is due to the dynamic nature of Python. You won=E2=80=99t get a = syntax >> error. You will get an exception: >>=20 >> NameError: name 'e' is not defined >>=20 >> Python has to assume that `e` might be defined at runtime. However, >> style checkers will complain. >=20 > OK, I'm aware about the dynamic nature but in this case it is somewhat > counter intuitive since it is part of the exception clause. You'd = except > the Python interpreter to complain. >=20 > So, is Flake8 like the standard to be used? >=20 > /Jarkko