[Patches] [ python-Patches-588728 ] __delete__ method-wraper

noreply@sourceforge.net noreply@sourceforge.net
Wed, 31 Jul 2002 01:28:05 -0700


Patches item #588728, was opened at 2002-07-30 19:33
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=588728&group_id=5470

Category: Core (C code)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nathan Srebro (nati)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: __delete__ method-wraper

Initial Comment:
In Python 2.2.1 (as well as in the current CVS), one
cannot access the __delete__ method of built-in
descriptors. This is particularly a problem when trying
to cooperatively subclass a built-in descriptor. Also,
defining a __delete__ method for a class (which is a
subclass of 'object'), does not have any effect unless
__set__ is also defined (it does only for old-style
classes).

This patch adds a method-wrapper for delete. This
solves the above two issues: property().__delete__ is
now properly defined, and defining a __delete__ method
now works even if __set__ is not deffined:

>>> class C(object):
...    def delx(self):
...       print "deled"
...    x = property(None,None,delx)
...
>>> a=C()
>>> C.__dict__['x'].__delete__(a)
deled
>>>
>>> 
>>> class prop(object):
... 	def __delete__(self,obj):
... 		print "deled"
... 
>>> class D(object):
... 	x = prop()
... 
>>> a = D()
>>> del a.x
deled
>>>


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

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