[Python-Dev] PEP 298

Thomas Heller theller@python.net
13 Dec 2002 15:02:02 +0100


Jack Jansen <Jack.Jansen@cwi.nl> writes:

> On Thursday, Dec 12, 2002, at 20:10 Europe/Amsterdam, Guido van Rossum
> wrote:
> 
> >> If you call YAGNI, it's ok for me, that's why I'm asking. Better save
> >> the time in this case...
> >
> > Well, I have no personal need for it.  If you're the only one, that
> > sounds like a big YAGNI to me...
> 
> Well... Note that you are currently living dangerously if you're using
> an s# format and access that buffer again after a
> Py_BEGIN_ALLOW_THREADS. If the object passed from Python was a mutable
> object with a buffer interface there's a chance that another thread
> has moved the underlying data.

It can even by the same thread, executing an innocent Py_DECREF()
can execute arbitrary Python code. Thinking of it, it's not clear
what you are allowed to do after PyArg_Parse() if you still need
the 'parsed pointers'.

And that's the main point of the PEP: the 'old' buffer interface
is nearly useless if you want too be safe.

Thomas