Skip to content

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

small fix for string representation of XPathSelector when the node is not an xml object

samus_5778ecf15dd4
diff --git a/scrapy/trunk/scrapy/xpath/selector.py b/scrapy/trunk/scrapy/xpath/selector.py
index 566ed53d5..bdc30cf89 100644
--- a/scrapy/trunk/scrapy/xpath/selector.py
+++ b/scrapy/trunk/scrapy/xpath/selector.py
@@ -78,7 +78,7 @@ class XPathSelector(object):
self.doc.xpathContext.xpathRegisterNs(prefix, uri)
def __str__(self):
- return "<%s (%s) xpath=%s>" % (type(self).__name__, getattr(self.xmlNode, 'name'), self.expr)
+ return "<%s (%s) xpath=%s>" % (type(self).__name__, getattr(self.xmlNode, 'name', type(self.xmlNode).__name__), self.expr)
__repr__ = __str__