From: Joel Brobecker <brobecker@adacore.com>
To: Pedro Alves <palves@redhat.com>
Cc: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Change method of loading .py files in Python tests
Date: Fri, 27 Jan 2017 04:33:00 -0000 [thread overview]
Message-ID: <20170127043235.irpmmnu6vjdf6bb5@adacore.com> (raw)
In-Reply-To: <d4708a87-2319-b656-7b7c-6a7d2101fed9@redhat.com>
> > 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
prev parent reply other threads:[~2017-01-27 4:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-21 4:52 Simon Marchi
2017-01-26 16:33 ` Pedro Alves
2017-01-26 21:13 ` Simon Marchi
2017-01-27 4:33 ` Joel Brobecker [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170127043235.irpmmnu6vjdf6bb5@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox