➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
标题: Patch cElementTree to export CurrentLineNumber
类型: enhancement Stage: resolved
Components: XML Versions: Python 3.2, Python 2.7
process
状态: closed Resolution: fixed
Dependencies: 后续: Update ElementTree with upstream changes
View: 6472
分配给: effbot 抄送列表: effbot, flox, georg.brandl, nnorwitz, robinbryce, robinbryce2
优先级: normal 关键字: patch

Created on 2006-08-11 13:27 by robinbryce2, last changed 2022-04-11 14:56 by admin. This issue is now closed.

文件
文件名 上传时间 Description 编辑
patch_against_51208.diff robinbryce2, 2006-08-11 13:27 [PATCH] pyexpat.c, _elementtree.c & test_xml_etree_c.py
Messages (6)
msg50868 - (view) Author: Robin Bryce (robinbryce2) 日期: 2006-08-11 13:27
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
msg50869 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) 日期: 2006-08-11 23:56
Logged In: YES 
user_id=33168

Fredrik, do you want etree patches here?
msg85282 - (view) Author: Fredrik Lundh (effbot) * (Python committer) 日期: 2009-04-03 00:00
In the upstream 1.0.6, the ParseError exception has a position attribute
that contains a (line, column) tuple.
msg85482 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) 日期: 2009-04-05 11:18
Which will be synced into core at some point, I guess?
msg86120 - (view) Author: Robin Bryce (robinbryce) 日期: 2009-04-18 15:10
> In the upstream 1.0.6, the ParseError exception has a position attribute
> that contains a (line, column) tuple.

That's fine for errors in the xml domain. Its not enough if I'm
reporting errors in the application domain - where I wont have a handy
exception to interrogate. What's the problem with just exposing the api
and requiring users who need it to use the streaming parser ?

Personally, I would have cached these details as a properties of the
_ElementInterface implementation for precisely this use case.
msg100859 - (view) Author: Florent Xicluna (flox) * (Python committer) 日期: 2010-03-11 14:49
ElementTree fixed in 2.7. See #6472.
历史
日期 用户 动作 参数
2022-04-11 14:56:19admin修改github: 43808
2010-03-11 14:49:26flox修改状态: open -> closed
后续: Update ElementTree with upstream changes
消息: + msg100859

dependencies: - Update ElementTree with upstream changes
resolution: postponed -> fixed
stage: patch review -> resolved
2010-02-13 16:05:16flox修改抄送: + flox
2010-02-13 16:01:18flox修改dependencies: + Update ElementTree with upstream changes
versions: + Python 3.2, - Python 3.1
2009-04-18 15:10:55robinbryce修改状态: pending -> open
抄送: + robinbryce
消息: + msg86120

2009-04-05 11:18:31georg.brandl修改状态: open -> pending

抄送: + georg.brandl
消息: + msg85482

resolution: postponed
2009-04-03 00:00:51effbot修改消息: + msg85282
2009-03-30 03:51:52ajaksu2修改stage: patch review
type: enhancement
components: + XML, - None
versions: + Python 3.1, Python 2.7
2006-08-11 13:27:12robinbryce2创建