Skip to content

Commit

Permalink
Merge pull request #149 from scrapy/better-error-message
Browse files Browse the repository at this point in the history
better error message when incorrect data is passed to Selector "text" argument
  • Loading branch information
eliasdorneles committed Oct 25, 2019
2 parents 3571df4 + 4be716d commit ce169cd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion parsel/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ def __init__(self, text=None, type=None, namespaces=None, root=None,

if text is not None:
if not isinstance(text, six.text_type):
raise TypeError("text argument should be of type %s" % six.text_type)
msg = "text argument should be of type %s, got %s" % (
six.text_type, text.__class__)
raise TypeError(msg)
root = self._get_root(text, base_url)
elif root is None:
raise ValueError("Selector needs either text or root argument")
Expand Down

0 comments on commit ce169cd

Please sign in to comment.