Skip to content

Commit ce169cd

Browse files
Merge pull request #149 from scrapy/better-error-message
better error message when incorrect data is passed to Selector "text" argument
2 parents 3571df4 + 4be716d commit ce169cd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

parsel/selector.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ def __init__(self, text=None, type=None, namespaces=None, root=None,
201201

202202
if text is not None:
203203
if not isinstance(text, six.text_type):
204-
raise TypeError("text argument should be of type %s" % six.text_type)
204+
msg = "text argument should be of type %s, got %s" % (
205+
six.text_type, text.__class__)
206+
raise TypeError(msg)
205207
root = self._get_root(text, base_url)
206208
elif root is None:
207209
raise ValueError("Selector needs either text or root argument")

0 commit comments

Comments
 (0)