Skip to content

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

check that no extra kwargs are silently discarded

Konstantin Lopuhinbcb92b50dc1d
diff --git a/scrapy/core/downloader/handlers/s3.py b/scrapy/core/downloader/handlers/s3.py
index cb2bb46b1..e218a8741 100644
--- a/scrapy/core/downloader/handlers/s3.py
+++ b/scrapy/core/downloader/handlers/s3.py
@@ -68,6 +68,9 @@ class S3DownloadHandler(object):
except Exception as ex:
raise NotConfigured(str(ex))
else:
+ kw.pop('anon', None)
+ if kw:
+ raise TypeError('Unexpected keyword arguments: %s' % kw)
if not self.anon:
SignerCls = botocore.auth.AUTH_TYPE_MAPS['s3']
self._signer = SignerCls(botocore.credentials.Credentials(
diff --git a/tests/test_downloader_handlers.py b/tests/test_downloader_handlers.py
index 57225ee3d..c0342b806 100644
--- a/tests/test_downloader_handlers.py
+++ b/tests/test_downloader_handlers.py
@@ -500,6 +500,10 @@ class S3TestCase(BaseS3TestCase):
mock_formatdate.return_value = date
yield
+ def test_extra_kw(self):
+ with self.assertRaises(TypeError):
+ S3DownloadHandler(Settings(), extra_kw=True)
+
def test_request_signing1(self):
# gets an object from the johnsmith bucket.
date ='Tue, 27 Mar 2007 19:36:42 +0000'