[lxml-dev] Trying to copy.copy() a node causes a segmentation fault
Trying to copy an xml node causes a segfault:
import copy
xmlsection xmlnode.find('sections').findall('section')[0]: original_section = copy.copy(xmlsection)
Segmentation fault -- dharana
dharana wrote:
Trying to copy an xml node causes a segfault:
import copy
xmlsection xmlnode.find('sections').findall('section')[0]: original_section = copy.copy(xmlsection)
Segmentation fault
Is this with lxml 0.7 or the SVN version? The svn version only supports deepcopy() as copy.copy() cannot be sensibly supported for lxml, but I guess I should be testing what happens if you do copy.copy.. What *should* happen anyway, anyone have an idea? Regards, Martijn
Martijn Faassen wrote:
dharana wrote:
Trying to copy an xml node causes a segfault:
import copy
xmlsection xmlnode.find('sections').findall('section')[0]: original_section = copy.copy(xmlsection)
Segmentation fault
Is this with lxml 0.7 or the SVN version? The svn version only supports deepcopy() as copy.copy() cannot be sensibly supported for lxml, but I guess I should be testing what happens if you do copy.copy.. What *should* happen anyway, anyone have an idea?
This is with lxml 0.7. I have no need to have it work with copy.copy because I the problem behind was node.find('somestring') evaluating to false. I believe if it's not supported it should just raise an Exception('not supported'). -- dharana
Martijn Faassen wrote:
The svn version only supports deepcopy() as copy.copy() cannot be sensibly supported for lxml, but I guess I should be testing what happens if you do copy.copy.. What *should* happen anyway, anyone have an idea?
According to the documentation: """A shallow copy constructs a new compound object and then (to the extent possible) inserts references into it to the objects found in the original.""" I interpret "to the extent possible" meaning that copy.copy() is permitted to do the same as copy.deepcopy() for cases like lxml as long as you document it. -- Robert Kern rkern@ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter
Robert Kern wrote:
Martijn Faassen wrote:
The svn version only supports deepcopy() as copy.copy() cannot be sensibly supported for lxml, but I guess I should be testing what happens if you do copy.copy.. What *should* happen anyway, anyone have an idea?
According to the documentation:
"""A shallow copy constructs a new compound object and then (to the extent possible) inserts references into it to the objects found in the original."""
I interpret "to the extent possible" meaning that copy.copy() is permitted to do the same as copy.deepcopy() for cases like lxml as long as you document it.
Good point! I'll also implement __copy__(). Okay, done and checked in. Thanks! Martijn
participants (3)
-
dharana
-
Martijn Faassen
-
Robert Kern