Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp72790ybz; Wed, 15 Apr 2020 04:47:16 -0700 (PDT) X-Google-Smtp-Source: APiQypJP3SiuYibEO2b/nb4ywzS3YS9V2meRbtuoWHNDbM59Y2bZ7E3oy9nK5zQeQ/X4Tr2087rt X-Received: by 2002:a05:6402:6ce:: with SMTP id n14mr23971074edy.144.1586951236003; Wed, 15 Apr 2020 04:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586951235; cv=none; d=google.com; s=arc-20160816; b=UcAexy2KX6HOpX418kQ0TbHt63u3aGpFXKFp0a3j/oVYqJEWuH1PdMYpZdUX9K2uzA ImbRyaVyitsgBo42jWFEJdOIHdoTbJ3Ykpu6J0afyTTD9BRbstXPF/yjJTeYZ2Whzp9M m2O+xqmfhKNIjjjH8ZxN3KgSq8ToAR5KZYeyVN6w1wzoadeGOrB1lZ8KeKiOeN9vs2ay 3R69i8yGTm7uo6U5CDbo56kpP4waDPATmMwgeGb1gwQpWTuw3OEalDOWsj36icplQzC8 UNCyXbwtrNRykBBjDTns6flCqK28G+FkrmIimtJ5YeSjBVKedzLjQjxhGOqfruFb7qe3 LaAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=Agr3OG2Py+zMOqDSa2vpkApzJG60IARnfczP3xvNakI=; b=IlxRFPFI1fKugkZEuzmgargOc21/GsdOZdreiuTkkrzemoKy66yrCNbkjmoohFRjdQ i7T/R60SKKrFxEd/4BXHFrLPMvoY5uvomN/B1ZQFRWmU34wDpn5JyXy9ypJXaKDL7I/j Kvlu9Eh4pFHTq5xgRm4J3fG1Rmjq6426VOwMUt9fWRRDq1QWOUB6p8fUmPINXkQJp6d3 oFI0JCs36Df3h1e4c4Qom/oPnHqZgZoHjt1C+VMHLknUGYW406/L3F/XfumbhcmF21vh 6+kF54NvAOw7AdvhqYO00UAgLZrIZcqi3mhOrcbo3zUBJMYn4icvU4drpLMEJ1YAlBwX 9pew== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si4186273edq.470.2020.04.15.04.46.52; Wed, 15 Apr 2020 04:47:15 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406758AbgDNHiq (ORCPT + 99 others); Tue, 14 Apr 2020 03:38:46 -0400 Received: from mga14.intel.com ([192.55.52.115]:17094 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406749AbgDNHil (ORCPT ); Tue, 14 Apr 2020 03:38:41 -0400 IronPort-SDR: AhOc6Pk2gJj8rAGBrfVsURJ7Iv+qYdSfVVNdQ6GZe2VOfqZ6aNHw9V9mI4MaSDt61opLn/v2ZM LcVwHQX05CRQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2020 00:38:40 -0700 IronPort-SDR: u+NegoB65VxBLzzbNz52A3oNkKqeXE5OURkh1WIUBU5g3XZQN7g+CDWy+Kk8vwu0Oqk7NcgKYc JSlvyFo/rVVA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,381,1580803200"; d="scan'208";a="399872713" Received: from elenamax-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.42.208]) by orsmga004.jf.intel.com with ESMTP; 14 Apr 2020 00:38:15 -0700 Date: Tue, 14 Apr 2020 10:38:06 +0300 From: Jarkko Sakkinen To: Ezra Buehler Cc: Shuah Khan , linux-kselftest@vger.kernel.org, linux-integrity@vger.kernel.org, Tadeusz Struk , open list Subject: Re: [PATCH] selftests/tpm2: Change exception handling to be Python 3 compatible Message-ID: <20200414073806.GE8403@linux.intel.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 14, 2020 at 07:45:33AM +0200, Ezra Buehler wrote: > Hi Jarkko, > > On 13 Apr 2020, at 20:04, Jarkko Sakkinen wrote: > > > > On Mon, Apr 13, 2020 at 07:02:20AM +0200, Ezra Buehler wrote: > >> Hi Jarkko, > >> > >> On 12 Apr 2020, at 19:07, Jarkko Sakkinen wrote: > >>> > >>> On Sun, Apr 12, 2020 at 05:02:27PM +0200, Ezra Buehler wrote: > >>>> Hi Jarkkon, > >>>> > >>>>> On 12 Apr 2020, at 16:36, Jarkko Sakkinen wrote: > >>>>> + except ProtocolError(e): > >>>> > >>>> Should this not be > >>>> > >>>> except ProtocolError as e: > >>> > >>> Unless there is a functional difference, does it matter? > >>> > >>> /Jarkko > >> > >> Well, your patch confuses me a lot. It looks to me like you are passing > >> the undefined `e` variable to the constructor. > >> > >> When I run flake8 on it I get following error (among others): > >> > >> F821 undefined name 'e' > > > > I don't know what flake8 is. > > https://flake8.pycqa.org/en/latest/ > > >> What I suggested is the standard syntax: > >> https://docs.python.org/3/tutorial/errors.html > > > > It passed the Python 3 interpreter. > > That is because it is technically valid syntax. > > >> Did you test this? You should get an error as soon as an exception > >> occurs. > > > > 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. > > That is due to the dynamic nature of Python. You won’t get a syntax > error. You will get an exception: > > NameError: name 'e' is not defined > > Python has to assume that `e` might be defined at runtime. However, > style checkers will complain. 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. So, is Flake8 like the standard to be used? /Jarkko