internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: boto/boto

Issue:
LaunchConfiguration does not retrieve AssociatePublicIpAddress properly
Pull request #1799 added support to `AssociatePublicIpAddress`, but it added only support for sending that parameter. Retrieval is not fully supported yet.

A simple fix would be grabbing what pull request #1832 implemented: https://github.com/boto/boto/pull/1832/files#diff-8c9af36969b22e4d4bb34924adc35399R105

My launch configuration object:

```
>>> launch_config.AssociatePublicIpAddress
u'true'

>>> launch_config.__class__
<class 'boto.ec2.autoscale.launchconfig.LaunchConfiguration'>
>>> pprint(dir(launch_config))
['AssociatePublicIpAddress',
 '__class__',
 '__delattr__',
 '__dict__',
 '__doc__',
 '__format__',
 '__getattribute__',
 '__hash__',
 '__init__',
 '__module__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 'associate_public_ip_address',
 'block_device_mappings',
 'connection',
 'created_time',
 'delete',
 'delete_on_termination',
 'ebs_optimized',
 'endElement',
 'image_id',
 'instance_monitoring',
 'instance_profile_name',
 'instance_type',
 'iops',
 'kernel_id',
 'key_name',
 'launch_configuration_arn',
 'member',
 'name',
 'ramdisk_id',
 'security_groups',
 'spot_price',
 'startElement',
 'user_data',
 'volume_type']
```

I am using boto version 2.23.0.



Discussion:

Resolving patch:
diff --git a/boto/ec2/autoscale/launchconfig.py b/boto/ec2/autoscale/launchconfig.py
--- a/boto/ec2/autoscale/launchconfig.py
+++ b/boto/ec2/autoscale/launchconfig.py
@@ -223,6 +223,8 @@ def endElement(self, name, value, connection):
             self.instance_profile_name = value
         elif name == 'EbsOptimized':
             self.ebs_optimized = True if value.lower() == 'true' else False
+        elif name == 'AssociatePublicIpAddress':
+            self.associate_public_ip_address = True if value.lower() == 'true' else False
         elif name == 'VolumeType':
             self.volume_type = value
         elif name == 'DeleteOnTermination':


Test patch:
Repository: boto/boto

Issue:
In 2.25.0 GoogleStorage generate_url() returns url with AWSAccessKeyId instead of GoogleAccessId
When generating a Google Storage signed url:

``` python
conn = boto.connect_gs(gs_access_key, gs_secret_access)
signed_url = conn.generate_url(900, 'GET', bucket=bucket_name, key=file_name)
```

signed_url is of the form:

https://bucket_name.storage.googleapis.com/file_name?Signature=foo&Expires=1392808714&**AWSAccessKeyId**=gs_access_key

But should be of the form:

https://bucket_name.storage.googleapis.com/file_name?Signature=foo&Expires=1392808714&**GoogleAccessId**=gs_access_key



Discussion:
It looks like the example at the veeery bottom of this page agrees with you:

https://developers.google.com/storage/docs/accesscontrol#Signed-URLs

@mfschwartz is using `AWSAccessKeyId` not supported or just not the recommended way to do this?

It looks like the value is hard-coded into the Google Storage class:

https://github.com/boto/boto/blob/develop/boto/gs/connection.py#L35

When using `AWSAccessKeyId` Google Storage replies with a 403 AccessDenied response

Yes, changing the line in https://github.com/boto/boto/blob/develop/boto/gs/connection.py#L35 to `QueryString = 'Signature=%s&Expires=%d&GoogleAccessId=%s'` fixes the issue.


Resolving patch:
diff --git a/boto/gs/connection.py b/boto/gs/connection.py
--- a/boto/gs/connection.py
+++ b/boto/gs/connection.py
@@ -32,7 +32,7 @@ class Location(object):
 class GSConnection(S3Connection):
 
     DefaultHost = 'storage.googleapis.com'
-    QueryString = 'Signature=%s&Expires=%d&AWSAccessKeyId=%s'
+    QueryString = 'Signature=%s&Expires=%d&GoogleAccessId=%s'
 
     def __init__(self, gs_access_key_id=None, gs_secret_access_key=None,
                  is_secure=True, port=None, proxy=None, proxy_port=None,


Test patch:
diff --git a/tests/integration/gs/test_basic.py b/tests/integration/gs/test_basic.py
--- a/tests/integration/gs/test_basic.py
+++ b/tests/integration/gs/test_basic.py
@@ -31,6 +31,7 @@
 import os
 import re
 import StringIO
+import urllib
 import xml.sax
 
 from boto import handler
@@ -99,6 +100,11 @@ def test_read_write(self):
         # check to make sure content read from gcs is identical to original
         self.assertEqual(s1, fp.read())
         fp.close()
+        # Use generate_url to get the contents
+        url = self._conn.generate_url(900, 'GET', bucket=bucket.name, key=key_name)
+        f = urllib.urlopen(url)
+        self.assertEqual(s1, f.read())
+        f.close()
         # check to make sure set_contents_from_file is working
         sfp = StringIO.StringIO('foo')
         k.set_contents_from_file(sfp)
Repository: boto/boto

Issue:
Cannot remove cookie stickiness policy from ELB listener
I can set policies no problem, but when I try to remove them by using a list of length 0 (`elb.set_policies_of_listener(80, [])`) I get the following error:

ValidationError: 1 validation error detected: Value null at 'policyNames' failed
 to satisfy constraint: Member must not be null



Discussion:

Resolving patch:
diff --git a/boto/ec2/elb/__init__.py b/boto/ec2/elb/__init__.py
--- a/boto/ec2/elb/__init__.py
+++ b/boto/ec2/elb/__init__.py
@@ -635,7 +635,10 @@ def set_lb_policies_of_listener(self, lb_name, lb_port, policies):
         """
         params = {'LoadBalancerName': lb_name,
                   'LoadBalancerPort': lb_port}
-        self.build_list_params(params, policies, 'PolicyNames.member.%d')
+        if len(policies):
+            self.build_list_params(params, policies, 'PolicyNames.member.%d')
+        else:
+            params['PolicyNames'] = ''
         return self.get_status('SetLoadBalancerPoliciesOfListener', params)
 
     def set_lb_policies_of_backend_server(self, lb_name, instance_port, policies):


Test patch:
diff --git a/tests/integration/ec2/elb/test_connection.py b/tests/integration/ec2/elb/test_connection.py
--- a/tests/integration/ec2/elb/test_connection.py
+++ b/tests/integration/ec2/elb/test_connection.py
@@ -198,6 +198,31 @@ def test_load_balancer_access_log(self):
             new_attributes.access_log.s3_bucket_prefix)
         self.assertEqual(5, new_attributes.access_log.emit_interval)
 
+    def test_set_load_balancer_policies_of_listeners(self):
+        more_listeners = [(443, 8001, 'HTTP')]
+        self.conn.create_load_balancer_listeners(self.name, more_listeners)
+
+        lb_policy_name = 'lb-policy'
+        self.conn.create_lb_cookie_stickiness_policy(
+            1000,
+            self.name,
+            lb_policy_name
+        )
+        self.conn.set_lb_policies_of_listener(
+            self.name,
+            self.listeners[0][0],
+            lb_policy_name
+        )
+
+        # Try to remove the policy by passing empty list.
+        # http://docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_SetLoadBalancerPoliciesOfListener.html
+        # documents this as the way to remove policies.
+        self.conn.set_lb_policies_of_listener(
+            self.name,
+            self.listeners[0][0],
+            []
+        )
+
 
 if __name__ == '__main__':
     unittest.main()
Repository: boto/boto

Issue:
TotalNumResults attribute of ResultSet from MTurkConnection.get_assignments is a unicode, not an int
Predictably, this bit me when I tried to compare TotalNumResults to the length of a list.

If this is deliberate, I think the documentation should be clarified. It currently describes the attribute as "A non-negative integer".



Discussion:
In the interest of backward compatibility I would suggest a documentation update to clarify what is being returned. Pull requests welcome.


Resolving patch:
diff --git a/boto/mturk/connection.py b/boto/mturk/connection.py
--- a/boto/mturk/connection.py
+++ b/boto/mturk/connection.py
@@ -388,15 +388,15 @@ def get_assignments(self, hit_id, status=None,
                 The number of assignments on the page in the filtered results
                 list, equivalent to the number of assignments being returned
                 by this call.
-                A non-negative integer
+                A non-negative integer, as a string.
         PageNumber
                 The number of the page in the filtered results list being
                 returned.
-                A positive integer
+                A positive integer, as a string.
         TotalNumResults
                 The total number of HITs in the filtered results list based
                 on this call.
-                A non-negative integer
+                A non-negative integer, as a string.
 
         The ResultSet will contain zero or more Assignment objects
 


Test patch:
diff --git a/tests/mturk/reviewable_hits.doctest b/tests/mturk/reviewable_hits.doctest
--- a/tests/mturk/reviewable_hits.doctest
+++ b/tests/mturk/reviewable_hits.doctest
@@ -84,10 +84,10 @@ True
 >>> len(assignments_rs) == int(assignments_rs.NumResults)
 True
 
->>> assignments_rs.PageNumber
-u'1'
+>>> int(assignments_rs.PageNumber)
+1
 
->>> assignments_rs.TotalNumResults >= 1
+>>> int(assignments_rs.TotalNumResults) >= 1
 True
 
 # should contain at least one Assignment object
Repository: boto/boto

Issue:
dynamodb.types.Binary can't handle non-ASCII strings on Python 2.7
The following happens when attempting to create a string from a dynamodb.types.Binary object representing non-ASCII characters for Python 2.7.5, boto v2.32.0:

```
>>> import boto.dynamodb.types
>>> str(boto.dynamodb.types.Binary('\xff'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "boto/dynamodb/types.py", line 174, in __str__
    return self.value.decode('utf-8')
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
```

Calling `str` on the Binary object should return a string with the same characters passed to the constructor.



Discussion:

Resolving patch:
diff --git a/boto/dynamodb/types.py b/boto/dynamodb/types.py
--- a/boto/dynamodb/types.py
+++ b/boto/dynamodb/types.py
@@ -148,10 +148,10 @@ def dynamize_value(val):
 if six.PY2:
     class Binary(object):
         def __init__(self, value):
-            if isinstance(value, six.text_type):  # Support only PY2 for backward compatibility.
-                value = value.encode('utf-8')
-            elif not isinstance(value, bytes):
+            if not isinstance(value, (bytes, six.text_type)):
                 raise TypeError('Value must be a string of binary data!')
+            if not isinstance(value, bytes):
+                value = value.encode("utf-8")
 
             self.value = value
 
@@ -171,7 +171,7 @@ def __repr__(self):
             return 'Binary(%r)' % self.value
 
         def __str__(self):
-            return self.value.decode('utf-8')
+            return self.value
 
         def __hash__(self):
             return hash(self.value)


Test patch:
diff --git a/tests/unit/dynamodb/test_types.py b/tests/unit/dynamodb/test_types.py
--- a/tests/unit/dynamodb/test_types.py
+++ b/tests/unit/dynamodb/test_types.py
@@ -86,6 +86,12 @@ def test_good_input(self):
         self.assertEqual(b'\x01', data)
         self.assertEqual(b'\x01', bytes(data))
 
+    def test_non_ascii_good_input(self):
+        # Binary data that is out of ASCII range
+        data = types.Binary(b'\x88')
+        self.assertEqual(b'\x88', data)
+        self.assertEqual(b'\x88', bytes(data))
+
     @unittest.skipUnless(six.PY2, "Python 2 only")
     def test_bad_input(self):
         with self.assertRaises(TypeError):
@@ -108,6 +114,9 @@ def test_unicode_py2(self):
         # In Python 2.x these are considered equal
         self.assertEqual(data, u'\x01')
 
+        # Check that the value field is of type bytes
+        self.assertEqual(type(data.value), bytes)
+
     @unittest.skipUnless(six.PY3, "Python 3 only")
     def test_unicode_py3(self):
         with self.assertRaises(TypeError):
Repository: boto/boto

Issue:
glacier: tree_hash returned as bytes by compute_hashes_from_fileobj 
When uploading a file to glacier, `compute_hashes_from_fileobj` uses `bytes_to_hex` from `glacier.utils`. `bytes_to_hex`, in turn, uses `binascii.hexlify()`. In Python 3 (I'm running v3.4), this now returns a `bytes` object, not a `str`.

This is eventually causing a `TypeError: Type str doesn't support the buffer API` exception in `auth.py`'s `canonical_headers` function since the hash value is used as a request header and is never converted from `bytes` to `str` but is operated on as if it were a `str`.



Discussion:

Resolving patch:
diff --git a/boto/auth.py b/boto/auth.py
--- a/boto/auth.py
+++ b/boto/auth.py
@@ -317,6 +317,8 @@ def headers_to_sign(self, http_request):
         for name, value in http_request.headers.items():
             lname = name.lower()
             if lname.startswith('x-amz'):
+                if isinstance(value, bytes):
+                    value = value.decode('utf-8')
                 headers_to_sign[name] = value
         return headers_to_sign
 


Test patch:
diff --git a/tests/unit/auth/test_sigv4.py b/tests/unit/auth/test_sigv4.py
--- a/tests/unit/auth/test_sigv4.py
+++ b/tests/unit/auth/test_sigv4.py
@@ -251,6 +251,17 @@ def test_pickle_works(self):
         auth2 = pickle.loads(pickled)
         self.assertEqual(auth.host, auth2.host)
 
+    def test_bytes_header(self):
+        auth = HmacAuthV4Handler('glacier.us-east-1.amazonaws.com',
+                                 mock.Mock(), self.provider)
+        request = HTTPRequest(
+            'GET', 'http', 'glacier.us-east-1.amazonaws.com', 80,
+            'x/./././x .html', None, {},
+            {'x-amz-glacier-version': '2012-06-01', 'x-amz-hash': b'f00'}, '')
+        canonical = auth.canonical_request(request)
+
+        self.assertIn('f00', canonical)
+
 
 class TestS3HmacAuthV4Handler(unittest.TestCase):
     def setUp(self):
Repository: boto/boto

Issue:
Calling cloudformation set_stack_policy results in KeyError: 'SetStackPolicyResult' 
I'm reading in a json file and using it to set a policy on a cloudformation stack. eg: cf.set_stack_policy(stack_name, stack_policy_body=stack_policy)

When I do this boto immediately returns:

File "/Library/Python/2.7/site-packages/boto/cloudformation/connection.py", line 888, in set_stack_policy
['SetStackPolicyResult']
KeyError: 'SetStackPolicyResult'

However when i check the policy on the cloudformation stack, I see the update did in fact complete, its just the bit around handling the return data that seems to fail afterwords.

The same json file I'm referencing as "stack_policy" above works fine when its passed to either create_stack or update_stack. Only set_stack_policy seems broken.



Discussion:

Resolving patch:
diff --git a/boto/cloudformation/connection.py b/boto/cloudformation/connection.py
--- a/boto/cloudformation/connection.py
+++ b/boto/cloudformation/connection.py
@@ -884,5 +884,4 @@ def set_stack_policy(self, stack_name_or_id, stack_policy_body=None,
             params['StackPolicyURL'] = stack_policy_url
 
         response = self._do_request('SetStackPolicy', params, '/', 'POST')
-        return response['SetStackPolicyResponse']\
-                       ['SetStackPolicyResult']
+        return response['SetStackPolicyResponse']


Test patch:
diff --git a/tests/unit/cloudformation/test_connection.py b/tests/unit/cloudformation/test_connection.py
--- a/tests/unit/cloudformation/test_connection.py
+++ b/tests/unit/cloudformation/test_connection.py
@@ -698,7 +698,7 @@ def test_set_stack_policy(self):
         self.set_http_response(status_code=200)
         api_response = self.service_connection.set_stack_policy('stack-id',
             stack_policy_body='{}')
-        self.assertEqual(api_response['Some'], 'content')
+        self.assertDictEqual(api_response, {'SetStackPolicyResult': {'Some': 'content'}})
         self.assert_request_parameters({
             'Action': 'SetStackPolicy',
             'ContentType': 'JSON',
Repository: boto/boto

Issue:
Wrong documentation for publish method in SNS connection
The method says `Get properties of a Topic`.



Discussion:

Resolving patch:
diff --git a/boto/sns/connection.py b/boto/sns/connection.py
--- a/boto/sns/connection.py
+++ b/boto/sns/connection.py
@@ -216,10 +216,10 @@ def delete_topic(self, topic):
     def publish(self, topic=None, message=None, subject=None, target_arn=None,
                 message_structure=None, message_attributes=None):
         """
-        Get properties of a Topic
+        Sends a message to all of a topic's subscribed endpoints
 
         :type topic: string
-        :param topic: The ARN of the new topic.
+        :param topic: The topic you want to publish to.
 
         :type message: string
         :param message: The message you want to send to the topic.


Test patch:
Repository: boto/boto

Issue:
S3 generate signed downloading url is not using response headers
I'm trying to generate a download url for an S3 file/key and want to change the filename when the downloaded file is saved locally (using the Content-Disposition header).

``` python
disposition = "attachment; filename=\"{}\"".format(file_name)
response_headers = {
    'response-content-disposition': disposition
}
key.generate_url(60 * 60, query_auth=True, response_headers=response_headers)
```

The [`key.generate_url`](https://github.com/boto/boto/blob/develop/boto/s3/key.py#L629) method uses the [`s3.connection.generate_url_sigv4` method](https://github.com/boto/boto/blob/develop/boto/s3/connection.py#L353) and this function doesn't seem to use the `response_headers` argument, so my Content-Disposition header is not used in the response.

In the normal `s3.connection.generate_url`, the response headers are [added to the query path](https://github.com/boto/boto/blob/develop/boto/s3/connection.py#L397-399) like described in the [S3 documentation](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html#RESTObjectGET-requests-request-parameters).

Kind regards,
Peter



Discussion:

Resolving patch:
diff --git a/boto/s3/connection.py b/boto/s3/connection.py
--- a/boto/s3/connection.py
+++ b/boto/s3/connection.py
@@ -366,6 +366,9 @@ def generate_url_sigv4(self, expires_in, method, bucket='', key='',
         if version_id is not None:
             params['VersionId'] = version_id
 
+        if response_headers is not None:
+            params.update(response_headers)
+
         http_request = self.build_base_http_request(method, path, auth_path,
                                                     headers=headers, host=host,
                                                     params=params)


Test patch:
diff --git a/tests/unit/s3/test_connection.py b/tests/unit/s3/test_connection.py
--- a/tests/unit/s3/test_connection.py
+++ b/tests/unit/s3/test_connection.py
@@ -155,6 +155,26 @@ def test_sigv4_presign_headers(self):
         self.assertIn('host', url)
         self.assertIn('x-amz-meta-key', url)
 
+    def test_sigv4_presign_response_headers(self):
+        self.config = {
+            's3': {
+                'use-sigv4': True,
+            }
+        }
+
+        conn = self.connection_class(
+            aws_access_key_id='less',
+            aws_secret_access_key='more',
+            host='s3.amazonaws.com'
+        )
+
+        response_headers = {'response-content-disposition': 'attachment; filename="file.ext"'}
+        url = conn.generate_url_sigv4(86400, 'GET', bucket='examplebucket',
+                                      key='test.txt', response_headers=response_headers)
+
+        self.assertIn('host', url)
+        self.assertIn('response-content-disposition', url)
+
 
 class TestUnicodeCallingFormat(AWSMockServiceTestCase):
     connection_class = S3Connection
Repository: boto/boto

Issue:
no_proxy support has some issues
If you have the `http_proxy` and `no_proxy` environment variables set, and then connect to a server listed in the no_proxy setting, boto sends:
`GET http://hostname/ HTTP/1.1`
instead of
`GET / HTTP/1.1`



Discussion:

Resolving patch:
diff --git a/boto/connection.py b/boto/connection.py
--- a/boto/connection.py
+++ b/boto/connection.py
@@ -1048,7 +1048,7 @@ def build_base_http_request(self, method, path, auth_path,
         if self.host_header and not boto.utils.find_matching_headers('host', headers):
             headers['host'] = self.host_header
         host = host or self.host
-        if self.use_proxy:
+        if self.use_proxy and not self.skip_proxy(host):
             if not auth_path:
                 auth_path = path
             path = self.prefix_proxy_to_path(path, host)


Test patch:
diff --git a/tests/unit/test_connection.py b/tests/unit/test_connection.py
--- a/tests/unit/test_connection.py
+++ b/tests/unit/test_connection.py
@@ -145,6 +145,24 @@ def test_get_proxy_url_with_auth(self):
         )
         self.assertEqual(conn.get_proxy_url_with_auth(), 'http://john.doe:p4ssw0rd@127.0.0.1:8180')
 
+    def test_build_base_http_request_noproxy(self):
+        os.environ['no_proxy'] = 'mockservice.cc-zone-1.amazonaws.com'
+
+        conn = AWSAuthConnection(
+            'mockservice.cc-zone-1.amazonaws.com',
+            aws_access_key_id='access_key',
+            aws_secret_access_key='secret',
+            suppress_consec_slashes=False,
+            proxy="127.0.0.1",
+            proxy_user="john.doe",
+            proxy_pass="p4ssw0rd",
+            proxy_port="8180"
+        )
+        request = conn.build_base_http_request('GET', '/', None)
+
+        del os.environ['no_proxy']
+        self.assertEqual(request.path, '/')
+
     def test_connection_behind_proxy_without_explicit_port(self):
         os.environ['http_proxy'] = "http://127.0.0.1"
         conn = AWSAuthConnection(