diff --git a/scrapy/http/request/__init__.py b/scrapy/http/request/__init__.py index 13a92ffa0..cd4360483 100644 --- a/scrapy/http/request/__init__.py +++ b/scrapy/http/request/__init__.py @@ -91,7 +91,7 @@ class Request(object_ref): """Create a new Request with the same attributes except for those given new values. """ - for x in ['url', 'method', 'headers', 'body', 'cookies', 'meta', + for x in ['url', 'method', 'headers', 'body', 'cookies', 'meta', 'flags', 'encoding', 'priority', 'dont_filter', 'callback', 'errback']: kwargs.setdefault(x, getattr(self, x)) cls = kwargs.pop('cls', self.__class__) diff --git a/tests/test_http_request.py b/tests/test_http_request.py index a042f03b6..fc89229c6 100644 --- a/tests/test_http_request.py +++ b/tests/test_http_request.py @@ -174,7 +174,8 @@ class RequestTest(unittest.TestCase): def somecallback(): pass - r1 = self.request_class("http://www.example.com", callback=somecallback, errback=somecallback) + r1 = self.request_class("http://www.example.com", flags=['f1', 'f2'], + callback=somecallback, errback=somecallback) r1.meta['foo'] = 'bar' r2 = r1.copy() @@ -184,6 +185,10 @@ class RequestTest(unittest.TestCase): assert r2.callback is r1.callback assert r2.errback is r2.errback + # make sure flags list is shallow copied + assert r1.flags is not r2.flags, "flags must be a shallow copy, not identical" + self.assertEqual(r1.flags, r2.flags) + # make sure meta dict is shallow copied assert r1.meta is not r2.meta, "meta must be a shallow copy, not identical" self.assertEqual(r1.meta, r2.meta)