Skip to content

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

minor improvements to Response.__repr__

Pablo Hoffman4f2925420f01
diff --git a/scrapy/http/request/__init__.py b/scrapy/http/request/__init__.py
index 00bd88759..cc86b6f5a 100644
--- a/scrapy/http/request/__init__.py
+++ b/scrapy/http/request/__init__.py
@@ -97,7 +97,7 @@ class Request(object_ref):
'body': self.body,
'cookies': self.cookies,
'meta': self.meta,
- }
+ }
return "%s(%s)" % (self.__class__.__name__, repr(d))
def copy(self):
diff --git a/scrapy/http/response/__init__.py b/scrapy/http/response/__init__.py
index 49a57dc5a..000b710e7 100644
--- a/scrapy/http/response/__init__.py
+++ b/scrapy/http/response/__init__.py
@@ -55,9 +55,15 @@ class Response(object_ref):
body = property(_get_body, _set_body)
def __repr__(self):
- return "%s(url=%s, headers=%s, status=%s, body=%s)" % \
- (type(self).__name__, repr(self.url), repr(self.headers), \
- repr(self.status), repr(self.body))
+ d = {
+ 'status': self.status,
+ 'url': self.url,
+ 'headers': self.headers,
+ 'body': self.body,
+ 'meta': self.meta,
+ 'flags': self.flags,
+ }
+ return "%s(%s)" % (self.__class__.__name__, repr(d))
def __str__(self):
flags = "(%s) " % ",".join(self.flags) if self.flags else ""