nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: boto/botocore
Pull request #520 (2015-04-17 20:45:03)

Add more helpful error message for positional args in clients
Before:

  TypeError: _api_call() takes exactly 1 argument (2 given)

After:

  TypeError: list_objects() only accepts keyword arguments.


From: https://github.com/boto/boto3/issues/35

cc @kyleknap


Patch:
diff --git a/botocore/client.py b/botocore/client.py
index 9627957bb..cd8c4bea4 100644
--- a/botocore/client.py
+++ b/botocore/client.py
@@ -186,7 +186,13 @@ class ClientCreator(object):
 
     def _create_api_method(self, py_operation_name, operation_name,
                            service_model):
-        def _api_call(self, **kwargs):
+        def _api_call(self, *args, **kwargs):
+            # We're accepting *args so that we can give a more helpful
+            # error message than TypeError: _api_call takes exactly
+            # 1 argument.
+            if args:
+                raise TypeError(
+                    "%s() only accepts keyword arguments." % py_operation_name)
             # The "self" in this scope is referring to the BaseClient.
             return self._make_api_call(operation_name, kwargs)
 


Test patch:
diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py
index 8a4c2db6a..529f6e13b 100644
--- a/tests/unit/test_client.py
+++ b/tests/unit/test_client.py
@@ -204,6 +204,14 @@ class TestAutoGeneratedClient(unittest.TestCase):
         response = service_client.test_operation(Foo='one', Bar='two')
         self.assertEqual(response, {})
 
+    def test_client_error_message_for_positional_args(self):
+        creator = self.create_client_creator()
+        service_client = creator.create_client(
+            'myservice', 'us-west-2', credentials=self.credentials)
+        with self.assertRaisesRegexp(TypeError,
+                                     'only accepts keyword arguments') as e:
+            service_client.test_operation('foo')
+
     @mock.patch('botocore.client.RequestSigner')
     def test_client_signs_call(self, signer_mock):
         creator = self.create_client_creator()
Repository: boto/botocore
Pull request #531 (2015-04-30 17:46:30)

Fix pagination issue
The issue is we need to stop paginating if we recieve an empty string for
a next token marker. Before, if we did not have a check to see that the next
token was not the same as the previous token and throw an error, we would have
hit an infinite loop.


Patch:
diff --git a/botocore/paginate.py b/botocore/paginate.py
index 59f28b119..6149b05c3 100644
--- a/botocore/paginate.py
+++ b/botocore/paginate.py
@@ -211,7 +211,13 @@ class PageIterator(object):
                 return [None]
         next_tokens = []
         for token in self._output_token:
-            next_tokens.append(token.search(parsed))
+            next_token = token.search(parsed)
+            # We do not want to include any empty strings as actual tokens.
+            # Treat them as None.
+            if next_token:
+                next_tokens.append(next_token)
+            else:
+                next_tokens.append(None)
         return next_tokens
 
     def result_key_iters(self):


Test patch:
diff --git a/tests/unit/test_paginate.py b/tests/unit/test_paginate.py
index ee485bc5f..3390f3b39 100644
--- a/tests/unit/test_paginate.py
+++ b/tests/unit/test_paginate.py
@@ -210,6 +210,23 @@ class TestFuturePaginator(unittest.TestCase):
              mock.call(Marker='m2', MaxKeys=1)]
         )
 
+    def test_with_empty_markers(self):
+        responses = [
+            {"Users": ["User1"], "Marker": ""},
+            {"Users": ["User1"], "Marker": ""},
+            {"Users": ["User1"], "Marker": ""}
+        ]
+        self.method.side_effect = responses
+        users = []
+        for page in self.paginator.paginate():
+            users += page['Users']
+        # We want to stop paginating if the next token is empty.
+        self.assertEqual(
+            self.method.call_args_list,
+            [mock.call()]
+        )
+        self.assertEqual(users, ['User1'])
+
     def test_build_full_result_with_single_key(self):
         responses = [
             {"Users": ["User1"], "Marker": "m1"},
Repository: boto/botocore
Pull request #560 (2015-06-15 22:31:54)

Scope sign request to service name
Even though botocore clients get a fresh copy of their event
emitter, we don't necessarily want to assume that non service
specific (or other service) events can be emitted from this
event emitter.

cc @kyleknap @mtdowling


Patch:
diff --git a/botocore/client.py b/botocore/client.py
index c76b2898f..411855c8c 100644
--- a/botocore/client.py
+++ b/botocore/client.py
@@ -285,12 +285,9 @@ class BaseClient(object):
         self.meta = ClientMeta(event_emitter, self._client_config,
                                endpoint.host, service_model,
                                self._PY_TO_OP_NAME)
-
-        # Register request signing, but only if we have an event
-        # emitter. When a client is cloned this is ignored, because
-        # the client's ``meta`` will be copied anyway.
-        if self.meta.events:
-            self.meta.events.register('request-created', self._sign_request)
+        self.meta.events.register('request-created.%s' %
+                                    service_model.service_name,
+                                    self._sign_request)
 
     @property
     def _service_model(self):


Test patch:
diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py
index d1f7eac5e..68422f37c 100644
--- a/tests/unit/test_client.py
+++ b/tests/unit/test_client.py
@@ -321,7 +321,8 @@ class TestAutoGeneratedClient(unittest.TestCase):
         creator = self.create_client_creator(event_emitter=event_emitter)
         creator.create_client(
             'myservice', 'us-west-2', credentials=self.credentials)
-        event_emitter.register.assert_called_with('request-created', mock.ANY)
+        event_emitter.register.assert_called_with('request-created.myservice',
+                                                  mock.ANY)
 
     def test_client_makes_call(self):
         creator = self.create_client_creator()