Stefan Behnel added the comment:

> As for backwards compatibility: yes, this is a concern. The keyword argument 
> would be a solution. On the other hand, I'm not sure that the default should 
> be something that causes dataloss...?

It's a matter of use cases. How often do people care? My experience tells me 
that it's much more common to parse XML in and extract information from it, 
than to do round trips. And when extracting information, both comments and 
processing instructions usually get in the way.

So I would say that this default behaviour isn't wrong. In fact, I'd even say 
that both lxml and ET behave as expected (or at least as intended) in their own 
ways.

Also, I can't really remember spotting a processing instruction anywhere 
*inside* of a root element in real world XML. For those living next to it, ET 
currently lacks support in its tree model.


> lxml sounds like it's doing the right things. Is there some connection 
> between lxml and etree that I'm not aware of, or did you just give it as an 
> example of how a different library behaves?

Both implement (essentially) the same API, so I consider compatibility and 
look-alikes important. The general idea is that lxml extends what's there, but 
otherwise tries to stay compatible as good as it can.

BTW, lxml also allows parser target objects to have "pi(self, target, data)" 
and "comment(text)" methods, through which it can pass comments and PIs through 
to user provided tree builders. I think ET lacks those, too.


Changing target version from 3.3/3.4 to 3.5 as this is a new feature that is 
unlikely to make it into a currently released (or close to release) Python 
version. Also changing the ticket type to enhancement as the current behaviour 
isn't "wrong". It's rather a matter of supporting an additional use case.

----------
type: behavior -> enhancement
versions: +Python 3.5 -Python 3.3, Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9521>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to