[lxml-dev] Serialization to file does not report error
Frédéric Mantegazza
mantegazza at ill.fr
Wed Jan 28 12:51:16 CET 2009
I use the following code to serialize a tree to a file:
tree.write(self.__fileName, pretty_print=True, xml_declaration=True)
if the file pointed by self.__fileName is not writable (not owned by the
current user), the call silently exits, but the file is not written. I have
to use:
file_ = file(self.__fileName, 'w')
tree.write(file_, pretty_print=True, xml_declaration=True)
file_.close()
to catch en exception in this case.
I'm using lxml 1.1.1; this is an old version (from debian etch), and it
might have been corrected in new release...
--
Frédéric
More information about the lxml-dev
mailing list