From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61896 invoked by alias); 26 Jan 2017 21:13:17 -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 61031 invoked by uid 89); 26 Jan 2017 21:13:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=HX-PHP-Originating-Script:rcube.php, H*u:1.2.3, H*UA:1.2.3, H*i:sk:d4708a8 X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Jan 2017 21:13:07 +0000 Received: by simark.ca (Postfix, from userid 33) id AB3DB1E165; Thu, 26 Jan 2017 16:13:04 -0500 (EST) To: Pedro Alves Subject: Re: [PATCH] Change method of loading .py files in Python tests X-PHP-Originating-Script: 33:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 26 Jan 2017 21:13:00 -0000 From: Simon Marchi Cc: gdb-patches@sourceware.org In-Reply-To: References: <20170121045243.1435-1-simon.marchi@polymtl.ca> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.2.3 X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg00606.txt.bz2 On 2017-01-26 11:33, Pedro Alves wrote: > 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, pushed with that fixed.