From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2065.outbound.protection.outlook.com [40.107.92.65]) by sourceware.org (Postfix) with ESMTPS id D765C3858D35 for ; Thu, 7 Mar 2024 10:00:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D765C3858D35 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D765C3858D35 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.92.65 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1709805622; cv=pass; b=rts1Gi6wk4S/UOldK949aIp+78iawm9EuufWwv+sjFn1RPpAIDZ6tqPysafPJoEG42qLRgmYSVB3HRKMkiZeljPxSP64MrNQ0yRkz5B1C6Mj+6uROdZtGvrd/vlNuMOWzyHIvAs+N0FfBJsnPsEJ/vezLmZkXLDbynJ1Lccu69E= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1709805622; c=relaxed/simple; bh=76j5F66j1C9nXSTTmeTB1WnYAhhQtIJA69QY8NTNi+8=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=RCp62ztPfw4YXaSu0Jza2roImII/EfgPXGjW2Ugp1uowEuLEsgTQ02qJvejla5qeXWEyM5bTGpwsEskFjNP+hyp5ueJKFjr5fCFmufz9GOblWKP2R9C6h6plb5KhubW6xvxGVI76AJZvMp9XcBdHjdsqBrVtaSdQiEUfelyuoT8= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NVvfckjbuwqrB1ygu6PtTi7366qJuT4xnG2+nGyULlsDGtO/9sSDfegKt2sHA+uEWWLGEXOuBOpO3VImEkvBMS81Hm8+dN3rdsKjQG2ujCqmwXvwqabojM4NjfM5LqwptjfBicScKgFdILboMIqHeENwNZLNTyfjmgqXf5e7kAJjflny5bGs3F6uMCi/H63HjHnbZcxUv+9Z+1GvjlZYxYFDg77ABqfcWT7h5f7RwIEQG2tbaItH0FOdum52HHLdqhfbzCxSKmpWRq0/vO6eCiHI2Ndva70qxRFR+76KBwpOj6JIsiB8M268ClsrhQdoQie1SDPOcNVNXqdESxG/5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=x4NClJuVeg0RVW4olr9/y3DixQTbdshtqve9Ivsm+4I=; b=CCqnTeMwbdOGhYr/viPCUz9TOC8+29RLp8u6kDXKsNU9NlHOGz9PChCWrcXF3tZZaBCmo+IziyUxa7h1Ffbh5f9tU3C8bbEzkuMcblEK834r+9REbb3bTpRjsouEXjaGcncIj8PTiYgsGFGIHh1BDPQzCek98bdXspS9teD2Oohf8ItogVIARBfl5ltXCPvhrDk6CEN3g47Tqgg/m/C3CHF2SJa4638y41haiM+F1tbYPstprwZOkPJRsHOS83lqPuOHh8OnNpczodX14Juf96aPSgIRtthE8boxM02IaXam5oNgmZYc+NPOcJ95q4ZlNZfVxEpmc3UZLCtX4cnwxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=adacore.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x4NClJuVeg0RVW4olr9/y3DixQTbdshtqve9Ivsm+4I=; b=b/5DNxEBOxJxRL4dtUo/jdNo2bje7Xk17Lz8DOXp/+xfSkW1bj8rv12G+XGMyE3v8d9WjpZW86GqP67uaLw47Ly62DtthfLQuqqIaEGG+dhktsojCT9XFwzdlogfBOMbahCMPuVF2Vxv4Cv3CWvrV4mkgX1ytr7OWQxhBAMePOQ= Received: from SN1PR12CA0049.namprd12.prod.outlook.com (2603:10b6:802:20::20) by PH0PR12MB8822.namprd12.prod.outlook.com (2603:10b6:510:28d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.26; Thu, 7 Mar 2024 10:00:18 +0000 Received: from SN1PEPF0002BA4E.namprd03.prod.outlook.com (2603:10b6:802:20:cafe::f7) by SN1PR12CA0049.outlook.office365.com (2603:10b6:802:20::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39 via Frontend Transport; Thu, 7 Mar 2024 10:00:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002BA4E.mail.protection.outlook.com (10.167.242.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7362.11 via Frontend Transport; Thu, 7 Mar 2024 10:00:18 +0000 Received: from khazad-dum (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 7 Mar 2024 04:00:17 -0600 Date: Thu, 7 Mar 2024 10:00:09 +0000 From: Lancelot SIX To: Tom Tromey CC: Subject: Re: [PATCH v4 3/4] Rewrite "python" command exception handling Message-ID: <20240307095930.442bsjiva4ss6hig@khazad-dum> References: <20240227-py-simple-exc-v4-0-3341d342c126@adacore.com> <20240227-py-simple-exc-v4-3-3341d342c126@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240227-py-simple-exc-v4-3-3341d342c126@adacore.com> X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4E:EE_|PH0PR12MB8822:EE_ X-MS-Office365-Filtering-Correlation-Id: 6eb1d218-b23f-4c15-4bff-08dc3e8d6523 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h65hry42Vm2urTWqd2tsaXnhmsfQKZkO4ZpNJlkVpGTmeiZ1zIpOamhU+aSfsTl5/f+Twq1IbyxkB6y11vmCyz/Q/HRPZ/sC2pa0pelhzQsfVWF5VNF7mEjP5k5NiKt01fpxwmyPJCcw8MCvdhUwd8MMtfefaLNDkBcGuRjiKO+ttwpJ+Wun5HP739JyCyj+KTu1nYS8ms58mRg+LQUcoXCLhNjnDQZzow17B59IGs0coIWIp9Xv0Pl0K33r8kAL6ikaXc3y/PGjQLE468CS7nfd7G5ou3Jo3YE8Pr2VxQ4Ig9PPKjcylc0vRCuWArSBpmznrIoOMR3Yf/D5Ps20SF1EUTqmJ3d0yXk+rTcivSR95MV2hH1EE+Qw/3152lwzAeLgr1wQ2N3xDUJLepccFSWEeF3e6Ds7YdQM7lhFxGzIC+iwS3ncETY1XSjgS97uId7gyqG4ZjJSEzstnAxjPe1FAG1cWMBZ4u5ulrCvX4FBKPg5S2karhwXQCX9dGiTEAukqH1TqGmRdU9FP6zmSgDbKYuIYhCcPehlfDGlPUv9u+4TjB14C/9KarYqsflBQ+0ogAclMTnfCsHJkAfl+GTd2PJTdGg4AhHgVPQKkjvkK588/KFX5RtfqO+stMWzSA9kQ5GG4HY+/H064b67X7Qp5wrmKB6LqytZAlBzmSw6CN7kCTTlSJqjnkx4Zv3jnGWISWjswxnShxSooHcTfQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(82310400014)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2024 10:00:18.7265 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6eb1d218-b23f-4c15-4bff-08dc3e8d6523 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002BA4E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8822 X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Feb 27, 2024 at 07:45:51AM -0700, Tom Tromey wrote: > The "python" command (and the Python implementation of the gdb > "source" command) does not handle Python exceptions in the same way as > other gdb-facing Python code. In particular, exceptions are turned > into a generic error rather than being routed through > gdbpy_handle_exception, which takes care of converting to 'quit' as > appropriate. > > I think this was done this way because PyRun_SimpleFile and friends do > not propagate the Python exception -- they simply indicate that one > occurred. > > This patch reimplements these functions to respect the general gdb > convention here. As a bonus, some Windows-specific code can be > removed, as can the _execute_file function. > > The bulk of this change is tweaking the test suite to match the new > way that exceptions are displayed. These changes are largely > uninteresting. However, it's worth pointing out the py-error.exp > change. Here, the failure changes because the test changes the host > charset to something that isn't supported by Python. This then > results in a weird error in the new setup. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31354 > Reviewed-By: Eli Zaretskii > Acked-By: Tom de Vries Hi Tom, Our internal testing caught a regression introduced by this change. Let's say you have a python script like this in /tmp/foo.py: if __name__ == "__main__": print(__file__) Before this patch, we would have: $ gdb -batch -quiet -x /tmp/foo.py /tmp/foo.py With this patch, we now have: $ gdb -batch -quiet -x /tmp/foo.py Python Exception : name '__file__' is not defined Error occurred in Python: name '__file__' is not defined I have not looked into much details, but can try to have a look if you don't have time. Best, Lancelot.