Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Small bugfix in selectors constructor regarding strings and unicodes

elpolilla66852b829135
diff --git a/scrapy/trunk/scrapy/xpath/selector.py b/scrapy/trunk/scrapy/xpath/selector.py
index f614f9f5f..da939bb91 100644
--- a/scrapy/trunk/scrapy/xpath/selector.py
+++ b/scrapy/trunk/scrapy/xpath/selector.py
@@ -3,7 +3,7 @@ import libxml2
from scrapy.http import Response
from scrapy.xpath.extension import Libxml2Document
from scrapy.xpath.constructors import xmlDoc_from_html, xmlDoc_from_xml
-from scrapy.utils.python import flatten
+from scrapy.utils.python import flatten, unicode_to_str
from scrapy.utils.misc import extract_regex
class XPathSelector(object):
@@ -28,7 +28,7 @@ class XPathSelector(object):
self.doc = Libxml2Document(response, constructor=constructor)
self.xmlNode = self.doc.xmlDoc
elif text:
- response = Response(domain=None, url=None, body=str(text))
+ response = Response(domain=None, url=None, body=unicode_to_str(text))
self.doc = Libxml2Document(response, constructor=constructor)
self.xmlNode = self.doc.xmlDoc
self.expr = expr