Commits

Gael Pasgrimaud committed cb35449

always init _parent

Comments (0)

Files changed (1)

                     elements.extend(r)
 
         list.__init__(self, elements)
+        self._parent = NoDefault
 
     def __call__(self, *args):
         # just return a new instance
         if len(args) == 1 and not args[0].startswith('<'):
             args += (self,)
         result = self.__class__(*args)
-        object.__setattr__(result, '_parent', self)
+        result._parent = self
         return result
+
     # keep original list api prefixed with _
     _append = list.append
     _extend = list.extend
         return self
 
     def replaceAll(self, expr):
+        if self._parent is NoDefault:
+            raise ValueError(
+                    'replaceAll can only be used with an object with parent')
         self._parent(expr).replaceWith(self)
         return self