Repository: boto/botocore

Issue:
Response from EC2 DescribeInstanceAttribute is incorrect
The response parser incorrectly duplicates the one returned value into all possible attributes creating a response like this:

```
$ aws --region us-east-1 ec2 describe-instance-attribute --instance `wget -q -O- http://169.254.169.254/latest/meta-data/instance-id` --attribute rootDeviceName 
{ 
"UserData": { 
"Value": "/dev/sda1" 
}, 
"ProductCodes": [], 
"InstanceId": "i-7a81571c✠", 
"InstanceInitiatedShutdownBehavior": { 
"Value": "/dev/sda1" 
}, 
"RootDeviceName": { 
"Value": "/dev/sda1" 
}, 
"EbsOptimized": { 
"Value": false 
}, 
"BlockDeviceMappings": [], 
"KernelId": { 
"Value": "/dev/sda1" 
}, 
"RamdiskId": { 
"Value": "/dev/sda1" 
}, 
"DisableApiTermination": { 
"Value": false 
}, 
"InstanceType": { 
"Value": "/dev/sda1" 
} 
} 
```



Discussion:

Resolving patch:
diff --git a/botocore/response.py b/botocore/response.py
--- a/botocore/response.py
+++ b/botocore/response.py
@@ -208,13 +208,18 @@ def _handle_boolean(self, elem, shape):
 
     def _handle_structure(self, elem, shape):
         new_data = {}
+        xmlname = shape.get('xmlname')
+        if xmlname:
+            tagname = self.get_element_base_tag(elem)
+            if xmlname != tagname:
+                return new_data
         for member_name in shape['members']:
             member_shape = shape['members'][member_name]
             xmlname = member_shape.get('xmlname', member_name)
             child = self.find(elem, xmlname)
             if child is not None:
-                new_data[member_name] = self.handle_elem(member_name, child,
-                                                         member_shape)
+                new_data[member_name] = self.handle_elem(
+                    member_name, child, member_shape)
         return new_data
 
     def _handle_list(self, elem, shape):


Test patch:
diff --git a/tests/unit/response_parsing/xml/responses/ec2-describe-instance-attribute.json b/tests/unit/response_parsing/xml/responses/ec2-describe-instance-attribute.json
new file mode 100644
--- /dev/null
+++ b/tests/unit/response_parsing/xml/responses/ec2-describe-instance-attribute.json
@@ -0,0 +1,18 @@
+{
+    "UserData": {}, 
+    "ResponseMetadata": {
+        "RequestId": "4c94c806-ef28-4f4c-b1c7-3e601fe39497"
+    }, 
+    "ProductCodes": [], 
+    "InstanceId": "i-12345678", 
+    "InstanceInitiatedShutdownBehavior": {}, 
+    "RootDeviceName": {
+        "Value": "/dev/sda1"
+    }, 
+    "EbsOptimized": {}, 
+    "BlockDeviceMappings": [], 
+    "KernelId": {}, 
+    "RamdiskId": {}, 
+    "DisableApiTermination": {}, 
+    "InstanceType": {}
+}
diff --git a/tests/unit/response_parsing/xml/responses/ec2-describe-instance-attribute.xml b/tests/unit/response_parsing/xml/responses/ec2-describe-instance-attribute.xml
new file mode 100644
--- /dev/null
+++ b/tests/unit/response_parsing/xml/responses/ec2-describe-instance-attribute.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<DescribeInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
+    <requestId>4c94c806-ef28-4f4c-b1c7-3e601fe39497</requestId>
+    <instanceId>i-12345678</instanceId>
+    <rootDeviceName>
+        <value>/dev/sda1</value>
+    </rootDeviceName>
+</DescribeInstanceAttributeResponse>
+