From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100224 invoked by alias); 27 Jan 2017 04:33:02 -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 99976 invoked by uid 89); 27 Jan 2017 04:32:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*f:sk:d4708a8, H*MI:sk:d4708a8, H*i:sk:d4708a8 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 27 Jan 2017 04:32:41 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 0C0601177ED; Thu, 26 Jan 2017 23:32:40 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id uQJpeWkwpIRs; Thu, 26 Jan 2017 23:32:39 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 9980E117412; Thu, 26 Jan 2017 23:32:39 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 1979A604BF; Fri, 27 Jan 2017 08:32:35 +0400 (RET) Date: Fri, 27 Jan 2017 04:33:00 -0000 From: Joel Brobecker To: Pedro Alves Cc: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH] Change method of loading .py files in Python tests Message-ID: <20170127043235.irpmmnu6vjdf6bb5@adacore.com> References: <20170121045243.1435-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.2-neo (2016-08-21) X-SW-Source: 2017-01/txt/msg00610.txt.bz2 > > 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. It is historical. At the beginning the idea of being able to source a Python script using "source" generated some disagreements, and we had to discuss a number of options before we could settle on a design that we could agree on. -- Joel