◐ Shell
clean mode source ↗

Message 50868 - Python tracker

This patch provides to the 'current' position expat api
via cElementTree.XMLTreeBuilder.

pyexpat already exposes this via the attributes
CurrentLineNumber, CurrentColumnNumber and
CurrentByteIndex. In order for cElementTree to do the
same, the following expat functions are added to those
exported via the pyexpat capi:
 * XML_CurrentLineNumber
 * XML_CurrentColumnNumber
 * XML_CurrentByteIndex

Then, in _elementtree.c, the xmlparser_getattr is made
to mirror the provisions made in pyexpat. A trivial
test is added to test_etree_c.py to cover the three new
attributes.

This patch was motivated by a discussion[1] on the
turbogears list that referenced two xml templating
libraries Kid & Markup. One of the benefits of the
latter is the ability to report line numbers for
template source errors.

If this patch is applied it should be possible for Kid,
and anything else that uses cElementTree for
xmlparsing, to do the same.

[1]
http://groups.google.com/group/turbogears/browse_frm/thread/1ed59ed984fc8bbe/1f06eb00e83f93d9#1f06eb00e83f93d9