# HG changeset patch # User cmlenz # Date 1155769592 0 # Node ID 110f90a0637c23f58a17f9f9f42415ae786529f1 # Parent 9df6f057efd36c0ae8b97d09561d552e89873b06 Report error when position predicates are used in XPath expressions (which is NYI). diff --git a/markup/path.py b/markup/path.py --- a/markup/path.py +++ b/markup/path.py @@ -359,6 +359,8 @@ assert self.cur_token == '[' self.next_token() expr = self._or_expr() + if isinstance(expr, NumberLiteral): + raise PathSyntaxError('Position predicates not yet supported') if self.cur_token != ']': raise PathSyntaxError('Expected "]" to close predicate, ' 'but found "%s"' % self.cur_token, diff --git a/markup/tests/path.py b/markup/tests/path.py --- a/markup/tests/path.py +++ b/markup/tests/path.py @@ -27,6 +27,9 @@ self.assertRaises(PathSyntaxError, Path, '..') self.assertRaises(PathSyntaxError, Path, 'parent::ma') + def test_error_position_predicate(self): + self.assertRaises(PathSyntaxError, Path, 'item[0]') + def test_1step(self): xml = XML('')