Eli Bendersky added the comment:

> I agree that [0] should be treated as a visible error as it's easy to get
> wrong. It's certainly too late to change this to 0-based indexing and I
> think it's ok to keep it 1-based for XPath compatibility (or at least
> similarity) as that's what people will expect it to mimic. I came up with a
> similar fix for lxml, BTW.
>
> Regarding the behaviour of negative indices, it's clearly broken and
> unexpected and "-1" is definitely not a valid XML tag name (as which it's
> currently interpreted). That's a change for Py3.4+ only though. Either
> disable negative indices completely and raise an exception at parse time or
> read "-X" as "last()-X". I would also be ok with the latter as it feels
> natural to support this in a Python context. But that's a new feature then,
> not a bug fix. And the fact that "last()-X" already exists tends to speak
> against it. It's more of an "if the intention is clear, why raise an
> exception" kind of thing.
>

Stefan,

IIUC, my recent commit (mirrored to the issue) is in accord with this
comment. Please correct me if I'm wrong.

----------

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

Reply via email to