Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix AttributeErrors thrown when LoadBalancerZones is used by adding e…
Browse files Browse the repository at this point in the history
…ndElement stub

LoadBalancerZones right now isn't actually a valid xml.sax Handler.  We just need to add an endElement stub so that the sax parser has something to call while parsing the object, otherwise it throws the below AttributeError:

"""
  File "/usr/lib/pymodules/python2.7/boto/ec2/elb/loadbalancer.py", line 173, in disable_zones
    new_zones = self.connection.disable_availability_zones(self.name, zones)
  File "/usr/lib/pymodules/python2.7/boto/ec2/elb/__init__.py", line 322, in disable_availability_zones
    params, LoadBalancerZones)
  File "/usr/lib/pymodules/python2.7/boto/connection.py", line 1114, in get_object
    xml.sax.parseString(body, h)
  File "/usr/lib/python2.7/xml/sax/__init__.py", line 49, in parseString
    parser.parse(inpsrc)
  File "/usr/lib/python2.7/xml/sax/expatreader.py", line 107, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "/usr/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
    self.feed(buffer)
  File "/usr/lib/python2.7/xml/sax/expatreader.py", line 207, in feed
    self._parser.Parse(data, isFinal)
  File "/usr/lib/python2.7/xml/sax/expatreader.py", line 304, in end_element
    self._cont_handler.endElement(name)
  File "/usr/lib/pymodules/python2.7/boto/handler.py", line 39, in endElement
    self.nodes[-1][1].endElement(name, self.current_text, self.connection)
AttributeError: 'LoadBalancerZones' object has no attribute 'endElement'
"""

Maybe all these classes should inherit from a base class which has a stub for startElement and endElement to make sure there is a safe fallback for the future?
  • Loading branch information
g2harris authored and toastdriven committed May 31, 2013
1 parent b8af9ca commit 215ffa2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions boto/ec2/elb/loadbalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def startElement(self, name, attrs, connection):
if name == 'AvailabilityZones':
return self.zones

def endElement(self, name, value, connection):
pass

class LoadBalancer(object):
"""
Expand Down

0 comments on commit 215ffa2

Please sign in to comment.