Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2505209ybb; Sun, 12 Apr 2020 07:39:21 -0700 (PDT) X-Google-Smtp-Source: APiQypJof4/d5JN4EEoT6PJanAvu+DQRdJTHSMUI5Wbdo5Lai6s39LM3ed5GdKbqETeLnQmJ2//B X-Received: by 2002:ac8:1757:: with SMTP id u23mr7538060qtk.138.1586702361434; Sun, 12 Apr 2020 07:39:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586702361; cv=none; d=google.com; s=arc-20160816; b=i0CZfdFOluqnzG4NGdalUTxdV0hut4l4XjB8die+hxcFPj2zam4lQQd/WNjTlZaMXC EtDR6F4m4vY1tkiHtjRkKUq0yr26yixj+Gn64VhPXqkxvtz+/KLm8dNydeCI8gzcCuha w481pYbrv+4oJI84RW4FVoxLIoQYMXUO1U24rsxQs+RGktvVMGP+TcrJi4EC5kOiWW49 DBbdj6k0FroYzRgvu+z2DRKuaB0K6sBuaUncSoUtjhNCadSjKfArs+b+F2Q+tz1+R5Si lBuKmEZVRKvSJONbhhKNCIv3DsPY5Iba8egIkuRyDxNcEuFonStkK5UTZG0vh/0CO22u fAwg== 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:ironport-sdr:ironport-sdr; bh=TLfX3Z7InWQXfbi0kQY53WpuZWRqYE/6V+78jcoUX1c=; b=gpd8pxSQQc+7YP8Mo94EV/guwPjYf9A/yaiGxNyCIfyM1HW1VSrvi9yduqvGfQWMaL xgM8YWe1ZagCnUDSWDiHoM1kJlO7xiAOXwq3M8PzsyvdUI3KYMHrpTf2hiqfBfvGl5nU AoKAqfwD9oL3hdTn+LO4SMy9eAksY0gCoYf3n/lIAa0Wc0stK1i+tKXxe+C8XMde5hyD RkjvLAS4BAMUnjdNlgTvd2VLqJkGziU77cfIDxLtV0RRmD422iinNOosbdXHTPbh0nfw AyHTkL/4ifHz04KycpLZ0DVS5qJqXXHvH68kRVLKDxuoVeSn5rCV87AFZtKRs6EeO1Lh x1zA== 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 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id s89si4204570qtd.387.2020.04.12.07.39.07; Sun, 12 Apr 2020 07:39:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727018AbgDLOhy (ORCPT + 99 others); Sun, 12 Apr 2020 10:37:54 -0400 Received: from mga06.intel.com ([134.134.136.31]:42870 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbgDLOhy (ORCPT ); Sun, 12 Apr 2020 10:37:54 -0400 IronPort-SDR: 6X6Y2a955p9PXJvQwseZExGI8zetNBY8qigwixeTfv46jevUnjlbpBvHeKvqcTBhx91JnNb7le XYuxp8SmvGtg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2020 07:37:54 -0700 IronPort-SDR: g5GvYPM/6OJkMkd1J5auhcXyQrxGN9ZljbobsePfIk+rccajZMSz7msFDjzYvmKFAlTFNY9jtF BhoCNlkV3IuQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,374,1580803200"; d="scan'208";a="452907895" Received: from apresura-mobl.ger.corp.intel.com (HELO localhost) ([10.252.61.246]) by fmsmga005.fm.intel.com with ESMTP; 12 Apr 2020 07:37:52 -0700 From: Jarkko Sakkinen To: Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-integrity@vger.kernel.org, Jarkko Sakkinen , Tadeusz Struk , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] selftests/tpm2: Change exception handling to be Python 3 compatible Date: Sun, 12 Apr 2020 17:36:54 +0300 Message-Id: <20200412143656.72955-1-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I need more time to fix all the byte array / string related stuff but it makes sense to fix the exceptions as it is fairly mechanical procedure: 1,$s/except \(.*\), \(.*\):/except \1(\2):/g I.e. fix the low hanging fruit first and the rest later. Signed-off-by: Jarkko Sakkinen --- tools/testing/selftests/tpm2/tpm2_tests.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/tpm2/tpm2_tests.py b/tools/testing/selftests/tpm2/tpm2_tests.py index 728be7c69b76..c3c06899e042 100644 --- a/tools/testing/selftests/tpm2/tpm2_tests.py +++ b/tools/testing/selftests/tpm2/tpm2_tests.py @@ -65,7 +65,7 @@ class SmokeTest(unittest.TestCase): blob = self.client.seal(self.root_key, data, auth, None) try: result = self.client.unseal(self.root_key, blob, auth[:-1] + 'B', None) - except ProtocolError, e: + except ProtocolError(e): rc = e.rc self.assertEqual(rc, tpm2.TPM2_RC_AUTH_FAIL) @@ -119,7 +119,7 @@ class SmokeTest(unittest.TestCase): self.client.policy_password(handle) result = self.client.unseal(self.root_key, blob, auth, handle) - except ProtocolError, e: + except ProtocolError(e): rc = e.rc self.client.flush_context(handle) except: @@ -136,7 +136,7 @@ class SmokeTest(unittest.TestCase): rc = 0 try: blob = self.client.seal(self.root_key, data, auth, None) - except ProtocolError, e: + except ProtocolError(e): rc = e.rc self.assertEqual(rc, tpm2.TPM2_RC_SIZE) @@ -152,7 +152,7 @@ class SmokeTest(unittest.TestCase): 0xDEADBEEF) self.client.send_cmd(cmd) - except IOError, e: + except IOError(e): rejected = True except: pass @@ -212,7 +212,7 @@ class SmokeTest(unittest.TestCase): self.client.tpm.write(cmd) rsp = self.client.tpm.read() - except IOError, e: + except IOError(e): # read the response rsp = self.client.tpm.read() rejected = True @@ -283,7 +283,7 @@ class SpaceTest(unittest.TestCase): rc = 0 try: space1.send_cmd(cmd) - except ProtocolError, e: + except ProtocolError(e): rc = e.rc self.assertEqual(rc, tpm2.TPM2_RC_COMMAND_CODE | -- 2.25.1