Restrict elementpath exceptions usage to ElementPathError

- Use only the base exception, others are derivation also of
    built-in exceptions.
This commit is contained in:
Davide Brunato 2019-05-29 06:53:55 +02:00
parent 7fce51361e
commit 0e9a3cb4c0
2 changed files with 4 additions and 4 deletions

View File

@ -13,7 +13,7 @@ This module contains declarations and classes for XML Schema constraint facets.
"""
from __future__ import unicode_literals
import re
from elementpath import XPath2Parser, ElementPathSyntaxError, ElementPathTypeError, datatypes
from elementpath import XPath2Parser, ElementPathError, datatypes
from ..compat import unicode_type, MutableSequence
from ..qnames import XSD_LENGTH, XSD_MIN_LENGTH, XSD_MAX_LENGTH, XSD_ENUMERATION, XSD_WHITE_SPACE, \
@ -665,7 +665,7 @@ class XsdAssertionFacet(XsdFacet):
try:
self.token = self.parser.parse(self.path)
except (ElementPathSyntaxError, ElementPathTypeError) as err:
except ElementPathError as err:
self.parse_error(err, elem=self.elem)
self.token = self.parser.parse('true()')

View File

@ -14,7 +14,7 @@ This module contains classes for other XML Schema identity constraints.
from __future__ import unicode_literals
import re
from collections import Counter
from elementpath import Selector, XPath1Parser, ElementPathSyntaxError, ElementPathKeyError
from elementpath import Selector, XPath1Parser, ElementPathError
from ..exceptions import XMLSchemaValueError
from ..qnames import XSD_UNIQUE, XSD_KEY, XSD_KEYREF, XSD_SELECTOR, XSD_FIELD
@ -66,7 +66,7 @@ class XsdSelector(XsdComponent):
try:
self.xpath_selector = Selector(self.path, self.namespaces, parser=XsdIdentityXPathParser)
except (ElementPathSyntaxError, ElementPathKeyError) as err:
except ElementPathError as err:
self.parse_error(err)
self.xpath_selector = Selector('*', self.namespaces, parser=XsdIdentityXPathParser)