The comment is parsed correctly and doc.getroottree().getprevious() returns it as expected. The bug is in serialization. _writePrevSiblings() in serializer.pxi omits declaration (as it should) and everything before it (as it should not).
Because lxml handles the declaration itself, instead of relying on libxml2, this is difficult to get right.
The comment is parsed correctly and doc.getroottree ().getprevious( ) returns it as expected. The bug is in serialization. _writePrevSibli ngs() in serializer.pxi omits declaration (as it should) and everything before it (as it should not).
Because lxml handles the declaration itself, instead of relying on libxml2, this is difficult to get right.