[lxml-dev] lxml iterparse generator not returning anything

Hi everyone, I'm finding that when using iterparse, the generator always throws StopIteration immediately, without returning any data. I must be doing something wrong, or I must have some kind of setup problem, but I'm struggling to work out what it is. If anybody has any ideas, then that would be greatly appreciated, or if this is a bug, I will raise it on the bug tracker. My version details are:
The most striking thing about this is that LIBXML_VERSION != LIBXML_COMPILED_VERSION, and LIBXSLT_VERSION != LIBXSLT_COMPILED_VERSION. If this version discrepancy is the real cause of the problem, then I think this issue is perhaps more appropriate for the Fedora mailing list, and you can ignore the rest of this mail. An example in which I am seeing this ( taken from http://codespeak.net/lxml/parsing.html#iterparse-and-iterwalk ) is: """ >>> from lxml import etree >>> from StringIO import StringIO >>> xml = '''<root> ... <element key='value'>text</element> ... <element>text</element>tail ... <empty-element xmlns="http://testns/" /> ... </root>''' >>> print xml <root> <element key='value'>text</element> <element>text</element>tail <empty-element xmlns="http://testns/" /> </root> >>> context = etree.iterparse(StringIO(xml)) >>> for action, elem in context: ... print("%s: %s" % (action, elem.tag)) end: element end: element end: {http://testns/}empty-element end: root """ if __name__ == '__main__': import doctest doctest.testmod() The result of putting this in a file and running it is that python complains: ********************************************************************** File "test.py", line 20, in __main__ Failed example: for action, elem in context: print("%s: %s" % (action, elem.tag)) Expected: end: element end: element end: {http://testns/}empty-element end: root Got nothing ********************************************************************** 1 items had failures: 1 of 6 in __main__ ***Test Failed*** 1 failures. Thanks in advance for any help, Joe Sarre This email and any attachments to it may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of Skyscanner. If you are not the intended recipient of this email, you must neither take any action based upon its contents, nor copy or show it to anyone. Please contact the sender if you believe you have received this email in error.

Joe Sarre, 30.03.2010 16:53:
I'm finding that when using iterparse, the generator always throws StopIteration immediately, without returning any data.
The only comment I can give on this one is that I've never seen this before. I'd first try to make sure it's really not a problem in your setup. Stefan

Joe Sarre, 30.03.2010 16:53:
I'm finding that when using iterparse, the generator always throws StopIteration immediately, without returning any data.
The only comment I can give on this one is that I've never seen this before. I'd first try to make sure it's really not a problem in your setup. Stefan
participants (2)
-
Joe Sarre
-
Stefan Behnel