[Patches] [ python-Patches-552438 ] PyBufferObject fixes

noreply@sourceforge.net noreply@sourceforge.net
Thu, 18 Jul 2002 12:41:37 -0700


Patches item #552438, was opened at 2002-05-05 00:26
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=552438&group_id=5470

Category: Core (C code)
Group: None
Status: Open
>Resolution: Out of Date
Priority: 5
Submitted By: Scott Gilbert (xscott)
>Assigned to: Tim Peters (tim_one)
Summary: PyBufferObject fixes

Initial Comment:
This patch fixes these problems:

  1) Dangling pointer problem
  2) buffer allocated by PyBuffer_New not aligned

The PyBufferObject acts differently depending on 
whether it allocated the memory or if it's borrowing 
the memory from a PyBufferProcs supporting object.

In the case of allocating it's own memory, I made a 
slight addition that adds some padding so that the ptr 
is on a sizeof(double) boundary.

In the case of borrowing another objects PyBufferProcs 
memory, PyBufferObject no longer caches the pointer.  
This might slow things down (probably not by much), 
but it keeps PyBufferObject from working with a stale 
pointer.


Normally I wouldn't do this, but since this patch 
touches pretty much every function anyway, I fixed 
many deviations from the Python coding style.



----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-07-18 15:41

Message:
Logged In: YES 
user_id=6380

Note, the patch is out of date since somebody fixed some
nits with slicing, so I'm marking this as Out Of Date.

You might as well upload the new version of the file. :-)

Why do you think you need to fix the allocation? Since
allocation is done via malloc(), and malloc() guarantees
allocation for a double ("for all types"), shouldn't that be
enough??? (If it's obmalloc that you're worried about, it's
easy to force this to use the real malloc() and free().)

I hope Tim will make some time to review this (the "not this
week" comment is several months old now). Superficially it
looks like a big improvement.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2002-05-07 14:51

Message:
Logged In: YES 
user_id=31435

Na, assigning a bug is fine by me -- it helps to have 
*someone* feel guilty <wink>.  Assigning it doesn't mean it 
goes to the top of the assignee's heap, though.  I can't 
make time to look at it this week, so it's just as well 
that it got unassigned.

----------------------------------------------------------------------

Comment By: Scott Gilbert (xscott)
Date: 2002-05-07 08:55

Message:
Logged In: YES 
user_id=38318

Apparently assigning a patch is poor form.  My bad.

----------------------------------------------------------------------

Comment By: Scott Gilbert (xscott)
Date: 2002-05-05 00:27

Message:
Logged In: YES 
user_id=38318

Can I assign this to you or does it take admin privs?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=552438&group_id=5470