Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG+1] exception handling was hiding original exception #38

Merged
merged 1 commit into from
Apr 25, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions parsel/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
XPath selectors based on lxml
"""

import sys

import six
from lxml import etree

Expand Down Expand Up @@ -175,9 +177,10 @@ def xpath(self, query):
try:
result = xpathev(query, namespaces=self.namespaces,
smart_strings=self._lxml_smart_strings)
except etree.XPathError:
msg = u"Invalid XPath: %s" % query
raise ValueError(msg if six.PY3 else msg.encode("unicode_escape"))
except etree.XPathError as exc:
msg = u"XPath error: %s in %s" % (exc, query)
msg = msg if six.PY3 else msg.encode('unicode_escape')
six.reraise(ValueError, ValueError(msg), sys.exc_info()[2])

if type(result) is not list:
result = [result]
Expand Down