[Patches] [Patch #103305] function attribute segfault

noreply@sourceforge.net noreply@sourceforge.net
Thu, 18 Jan 2001 13:30:58 -0800


Patch #103305 has been updated. 

Project: python
Category: core (C code)
Status: Open
Submitted by: greg_ball
Assigned to : bwarsaw
Summary: function attribute segfault

Follow-Ups:

Date: 2001-Jan-18 13:30
By: bwarsaw

Comment:
Assigning this to me to look at later.
-------------------------------------------------------

Date: 2001-Jan-17 14:51
By: greg_ball

Comment:
I have ready a new version of the patch
(I won't upload it yet in case it's not welcome)
which does the following:

reference to f.__dict__ or f.func_dict returns a new dictionary if f did
not previously have one.  (Similar to what happens on first assignent to
arbitrary attribute.)

Then the following code works:

>>> def f(): pass
... 
>>> d=f.__dict__
>>> f.a=1
>>> d['a']
1

instead of d being an unsubscriptable object.
To me it seems nasty if somethings __dict__ attribute
might not be a dictionary.

Since f.__dict__ never now _appears_ to be None,
I also removed the feature of assigning it to None to get rid of it.
del f.__dict__ can now be used for this purpose.
(previously only for creating sig11 =) )


One other thought:  as it stands, function attributes are strangely
behaving in restricted mode.  You can't set any attributes directly. You
can't directly get attributes that don't start with an underscore. 
However, you can get __dict__ and then do anything you like to it...


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

Date: 2001-Jan-17 14:03
By: greg_ball

Comment:
At two points, the code did not check for NULL,
leading to segmentation fault soon after.

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

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=103305&group_id=5470