[Lxml-checkins] r51495 - in lxml/trunk: . src/lxml
scoder at codespeak.net
scoder at codespeak.net
Thu Feb 14 21:12:02 CET 2008
Author: scoder
Date: Thu Feb 14 21:12:01 2008
New Revision: 51495
Modified:
lxml/trunk/ (props changed)
lxml/trunk/src/lxml/lxml.objectify.pyx
Log:
r3510 at delle: sbehnel | 2008-02-14 21:04:10 +0100
cleanup of ObjectifiedElement.__delitem__()
Modified: lxml/trunk/src/lxml/lxml.objectify.pyx
==============================================================================
--- lxml/trunk/src/lxml/lxml.objectify.pyx (original)
+++ lxml/trunk/src/lxml/lxml.objectify.pyx Thu Feb 14 21:12:01 2008
@@ -317,26 +317,17 @@
def __delitem__(self, key):
cdef Py_ssize_t start, stop, step, slicelength
+ parent = self.getparent()
+ if parent is None:
+ raise TypeError("deleting items not supported by root element")
if python.PySlice_Check(key):
# slice deletion
- python.PySlice_GetIndicesEx(
- key, _countSiblings(self._c_node),
- &start, &stop, &step, &slicelength)
- parent = self.getparent()
- if parent is None:
- raise TypeError("deleting slices of root element not supported")
- if step < 0:
- del_items = list(self)[start:stop:step]
- else:
- del_items = list(islice(self, start, stop, step))
+ del_items = list(self)[key]
remove = parent.remove
for el in del_items:
remove(el)
else:
# normal index deletion
- parent = self.getparent()
- if parent is None:
- raise TypeError("deleting items not supported by root element")
sibling = self.__getitem__(key)
parent.remove(sibling)
More information about the lxml-checkins
mailing list