[Patches] [Patch #103305] function attribute segfault
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 19 Jan 2001 11:46:15 -0800
Patch #103305 has been updated.
Project: python
Category: core (C code)
Status: Closed
Submitted by: greg_ball
Assigned to : bwarsaw
Summary: function attribute segfault
Follow-Ups:
Date: 2001-Jan-19 11:46
By: bwarsaw
Comment:
Sorry, one more try.
-------------------------------------------------------
Date: 2001-Jan-19 11:45
By: bwarsaw
Comment:
Oops, I forgot to write out the new patch. Here 'tis for the historical
record.
-------------------------------------------------------
Date: 2001-Jan-19 11:43
By: bwarsaw
Comment:
Attached is a new version of this patch, which I'm about to check in.
greg_ball's patch and discovery of the bug was excellent, but there were a
few other things to clean up in the file too (crashing on del
f.func_defaults, raising the wrong exception when del'ing a non-existant
attribute).
Applying and closing.
-------------------------------------------------------
Date: 2001-Jan-18 17:57
By: gvanrossum
Comment:
This is a high priority patch -- needs to be deal with before 2.1a1 can go
out.
-------------------------------------------------------
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