This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Use Python 2.[67] / 3.X / PEP 3118 buffer protocol
- From: Tom Tromey <tom at tromey dot com>
- To: Kevin Buettner <kevinb at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 20 Feb 2019 11:13:35 -0700
- Subject: Re: [PATCH] Use Python 2.[67] / 3.X / PEP 3118 buffer protocol
- References: <20190219145110.03bccce6@f29-4.lan>
>>>>> "Kevin" == Kevin Buettner <kevinb@redhat.com> writes:
Kevin> This patch removes the non-IS_PY3K code in infpy_write_memory()
Kevin> and infpy_search_memory(). In both cases, the remaining code
Kevin> from these ifdefs is related to use of the PEP 3118 buffer protocol.
Kevin> (Deleted code is either due to simplification or related to use of the
Kevin> old buffer protocol.) PEP 3118 is sometimes referred to as the "new"
Kevin> buffer protocol, though it's not that new anymore.
Thanks for doing this.
Kevin> The link below describes new features in Python 2.6. In particular,
Kevin> it says that the buffer protocol described by PEP 3118 is in Python
Kevin> 2.6. It also says (at the top of the page) that Python 2.6 was
Kevin> released on Oct 1, 2008.
I think probably the NEWS file should be updated to mention the minimum
version bump. gdb.texinfo also currently says that Python 2.4 is the
minimum, so that should also be updated.
Kevin> I have tested against both Python 2.7.15 and 3.7.2. I see no
Kevin> regressions among the non-racy tests. I've also verified that
Kevin> PyBuffer_Release is being called when the affected functions exit
Kevin> while running the tests in gdb.python/py-inferior.exp by hand. I've
Kevin> also tried running valgrind on GDB while running this test, but I'm
Kevin> puzzled by the results that I'm seeing - I'm seeing no additional
Kevin> leaks when I comment out the Py_buffer_up lines that I introduced.
Maybe it's possible that PyBuffer_Release doesn't need to do anything in
particular in some scenarios? Like if the buffer it refers to is shared
with some other object? You'd have to dive into the Python
implementation to find out. Meanwhile if there is no leak introduced by
this code, then it seems fine to me.
The patch itself looks good to me.
Tom