Merge branch '0.14' of github.com:scrapy/scrapy into 0.14

This commit is contained in:
Pablo Hoffman 2012-02-11 20:29:51 -02:00
commit 1627320264
3 changed files with 10 additions and 3 deletions

View File

@ -106,9 +106,13 @@ class ExecutionEngine(object):
if slot.start_requests and not self._needs_backout(spider):
try:
request = slot.start_requests.next()
self.crawl(request, spider)
except StopIteration:
slot.start_requests = None
except Exception, exc:
log.err(None, 'Obtaining request from start requests', \
spider=spider)
else:
self.crawl(request, spider)
if self.spider_is_idle(spider) and slot.close_if_idle:
self._spider_idle(spider)

View File

@ -54,8 +54,7 @@ class Request(object_ref):
if self.encoding is None:
raise TypeError('Cannot convert unicode url - %s has no encoding' %
type(self).__name__)
unicode_url = url if isinstance(url, unicode) else url.decode(self.encoding)
self._url = safe_url_string(unicode_url, self.encoding)
self._set_url(url.encode(self.encoding))
else:
raise TypeError('Request url must be str or unicode, got %s:' % type(url).__name__)
if ':' not in self._url:

View File

@ -108,8 +108,12 @@ class RequestTest(unittest.TestCase):
self.assertEqual(r4.body, "Price: \xa3100")
def test_ajax_url(self):
# ascii url
r = self.request_class(url="http://www.example.com/ajax.html#!key=value")
self.assertEqual(r.url, "http://www.example.com/ajax.html?_escaped_fragment_=key=value")
# unicode url
r = self.request_class(url=u"http://www.example.com/ajax.html#!key=value")
self.assertEqual(r.url, "http://www.example.com/ajax.html?_escaped_fragment_=key=value")
def test_copy(self):
"""Test Request copy"""