def generate_deletion_code(self, code):
interned_attr_cname = code.intern_identifier(self.attribute)
self.obj.generate_evaluation_code(code)
- if self.is_py_attr:
+ if self.is_py_attr or (isinstance(self.entry.scope, Symtab.PropertyScope)
+ and self.entry.scope.entries.has_key(u'__del__')):
code.put_error_if_neg(self.pos,
'PyObject_DelAttr(%s, %s)' % (
self.obj.py_result(),
def __set__(self, value):
ATTR = value
""", level='c_class')
+ basic_pyobject_property = TreeFragment(u"""
+property NAME:
+ def __get__(self):
+ return ATTR
+ def __set__(self, value):
+ ATTR = value
+ def __del__(self):
+ ATTR = None
+ """, level='c_class')
basic_property_ro = TreeFragment(u"""
property NAME:
def __get__(self):
def create_Property(self, entry):
if entry.visibility == 'public':
- template = self.basic_property
+ if entry.type.is_pyobject:
+ template = self.basic_pyobject_property
+ else:
+ template = self.basic_property
elif entry.visibility == 'readonly':
template = self.basic_property_ro
property = template.substitute({
_ERRORS = u"""
5:20: Illegal use of special attribute __weakref__
5:20: Illegal use of special attribute __weakref__
+5:20: Illegal use of special attribute __weakref__
5:20: Special attribute __weakref__ cannot be exposed to Python
8:22: Illegal use of special attribute __weakref__
8:22: Special attribute __weakref__ cannot be exposed to Python
>>> lines = __test__.keys()
>>> len(lines)
- 2
+ 3
>>> 'Spam.eggs.__get__ (line 5)' in lines
True
>>> 'tomato (line 11)' in lines
spam = Spam()
lettuce = spam.eggs
return lettuce
+
+cdef class Bacon(object):
+ cdef object number_of_slices
+ cdef public object is_a_vegetable
+
+def breakfast():
+ """
+ >>> breakfast()
+ """
+ cdef Bacon myslices = Bacon()
+ myslices.is_a_vegetable = True
+ assert myslices.is_a_vegetable, myslices.is_a_vegetable
+ del myslices.is_a_vegetable
+ assert myslices.is_a_vegetable is None, myslices.is_a_vegetable