Hi,

On 04/04/2011 09:52 AM, bertrand neron wrote:
On 04/01/2011 05:49 PM, Stefan Behnel wrote:
bertrand neron, 01.04.2011 17:12:
Since the version 2.3 of lxml, I have a problem with parse function of
etree. When I a provide an open file object to the etree.parse function,
the file object is automatically closed by parse.

Is there a way to keep the file open?
That was specifically changed in order to prevent dangling open files.

Would you care to give some hints about your use case?

Stefan
I have concurrent access to the xml file I must parse. So after opening
file I acquire a lock on this file. I parse the xml, then modify it and
serialize it before release the lock on the file.

but now I cannot use lock anymore. I'd like the parse function does not
modify the open/close status of the file given as argument.

bertrand
I second the opinion of Bertrand. Actually, IMHO, the problem is that the "parse" method processes either a file path or a file handle: in the case where we provide a file path, the file should of course be closed after being read, but in the case where we provide a file handle, I think it is the responsibility of the "caller code" to close the file.
By the way, thank you very much to all of the author(s) of lxml, it's a really performant library, switching to it really gained us much performance.

Hervé
_________________________________________________________________ Mailing list for the lxml Python XML toolkit - http://lxml.de/ lxml@lxml.de http://mailman-mail5.webfaction.com/listinfo/lxml