From bcb92b50dc1d1106ee418d6d7a701d87cde4010c Mon Sep 17 00:00:00 2001 From: Konstantin Lopuhin Date: Fri, 5 Feb 2016 17:38:47 +0300 Subject: [PATCH] check that no extra kwargs are silently discarded --- scrapy/core/downloader/handlers/s3.py | 3 +++ tests/test_downloader_handlers.py | 4 ++++ 2 files changed, 7 insertions(+) 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' -- GitLab