nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: scrapy/scrapy
Pull request #4153 (2019-11-13 08:47:59)

MutableChain: return self from __iter__
https://lgtm.com/rules/4850080/


Patch:
diff --git a/scrapy/utils/python.py b/scrapy/utils/python.py
index ea5193f12..6edf7d702 100644
--- a/scrapy/utils/python.py
+++ b/scrapy/utils/python.py
@@ -388,9 +388,11 @@ class MutableChain(object):
         self.data = chain(self.data, *iterables)
 
     def __iter__(self):
-        return self.data.__iter__()
+        return self
 
     def __next__(self):
         return next(self.data)
 
-    next = __next__
+    @deprecated("scrapy.utils.python.MutableChain.__next__")
+    def next(self):
+        return self.__next__()


Test patch:
diff --git a/tests/test_utils_python.py b/tests/test_utils_python.py
index 3e1148354..ca2c241e4 100644
--- a/tests/test_utils_python.py
+++ b/tests/test_utils_python.py
@@ -5,6 +5,7 @@ import unittest
 from itertools import count
 import platform
 import six
+from warnings import catch_warnings
 
 from scrapy.utils.python import (
     memoizemethod_noargs, binary_is_text, equal_attributes,
@@ -21,8 +22,12 @@ class MutableChainTest(unittest.TestCase):
         m.extend([7, 8])
         m.extend([9, 10], (11, 12))
         self.assertEqual(next(m), 0)
-        self.assertEqual(m.next(), 1)
-        self.assertEqual(m.__next__(), 2)
+        self.assertEqual(m.__next__(), 1)
+        with catch_warnings(record=True) as warnings:
+            self.assertEqual(m.next(), 2)
+            self.assertEqual(len(warnings), 1)
+            self.assertIn('scrapy.utils.python.MutableChain.__next__',
+                          str(warnings[0].message))
         self.assertEqual(list(m), list(range(3, 13)))
Repository: scrapy/scrapy
Pull request #4293 (2020-01-29 13:06:55)

[HttpCompressionMiddleware] fix delimiter for Accept-Encoding header
Accept-Encoding header should have `, `  (with space) as a delimiter between encodings instead of `,` (non space) (https://tools.ietf.org/html/rfc2616#section-14.3)


Patch:
diff --git a/scrapy/downloadermiddlewares/httpcompression.py b/scrapy/downloadermiddlewares/httpcompression.py
index 65b652953..0010b2a8f 100644
--- a/scrapy/downloadermiddlewares/httpcompression.py
+++ b/scrapy/downloadermiddlewares/httpcompression.py
@@ -26,7 +26,7 @@ class HttpCompressionMiddleware(object):
 
     def process_request(self, request, spider):
         request.headers.setdefault('Accept-Encoding',
-                                   b",".join(ACCEPTED_ENCODINGS))
+                                   b", ".join(ACCEPTED_ENCODINGS))
 
     def process_response(self, request, response, spider):
 


Test patch:
diff --git a/tests/test_downloadermiddleware_httpcompression.py b/tests/test_downloadermiddleware_httpcompression.py
index c6a823b53..64488841a 100644
--- a/tests/test_downloadermiddleware_httpcompression.py
+++ b/tests/test_downloadermiddleware_httpcompression.py
@@ -48,7 +48,7 @@ class HttpCompressionTest(TestCase):
                 }
 
         response = Response('http://scrapytest.org/', body=body, headers=headers)
-        response.request = Request('http://scrapytest.org', headers={'Accept-Encoding': 'gzip,deflate'})
+        response.request = Request('http://scrapytest.org', headers={'Accept-Encoding': 'gzip, deflate'})
         return response
 
     def test_process_request(self):
@@ -56,7 +56,7 @@ class HttpCompressionTest(TestCase):
         assert 'Accept-Encoding' not in request.headers
         self.mw.process_request(request, self.spider)
         self.assertEqual(request.headers.get('Accept-Encoding'),
-                         b','.join(ACCEPTED_ENCODINGS))
+                         b', '.join(ACCEPTED_ENCODINGS))
 
     def test_process_response_gzip(self):
         response = self._getresponse('gzip')