From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84635 invoked by alias); 26 Jan 2017 16:33:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 84543 invoked by uid 89); 26 Jan 2017 16:33:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=$test X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Jan 2017 16:33:29 +0000 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D569CC05681B; Thu, 26 Jan 2017 16:33:29 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A05B1629ED; Thu, 26 Jan 2017 16:33:25 +0000 (UTC) Subject: Re: [PATCH] Change method of loading .py files in Python tests To: Simon Marchi , gdb-patches@sourceware.org References: <20170121045243.1435-1-simon.marchi@polymtl.ca> From: Pedro Alves Message-ID: Date: Thu, 26 Jan 2017 16:33:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170121045243.1435-1-simon.marchi@polymtl.ca> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-01/txt/msg00588.txt.bz2 On 01/21/2017 04:52 AM, Simon Marchi wrote: > With my debug build of Python (--with-pydebug), many tests fails because > of the same issue. Python scripts are loaded by the tests using this > pattern: > > (gdb) python exec (open ('file.py').read ()) > > This causes Python to output this warning: > > __main__:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='file.py' mode='r' encoding='ANSI_X3.4-1968'> > > and the test to fail because of that extra output. Instead of using the > open + read + exec trick which leaks the file and causes the warning, > why not just source the files? > > (gdb) source file.py Maybe historical. ISTR that "source" didn't read in python files automatically originally. But I may easily be misremembering. > > This patch changes this, and standardizes the test names of the tests I > touched to "load python file" (some of them were empty, others were > overly complicated). Guess we could have: proc gdb_load_python_file { pyfile {test "load python file"} } { gdb_test_no_output "source $pyfile" $test } But what you have LGTM. > -gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \ > - "load python file for no debuginfo tests" > +gdb_test_no_output "source ${remote_python_file}" "load python file for no debuginfo tests" Long line? Thanks, Pedro Alves