Skip to content

Commit

Permalink
Handle empty return bodies when processing S3 errors.
Browse files Browse the repository at this point in the history
Currently error commands that do not return a body cause
s3cmd to output an ugly backtrace. This change checks to
see if the data field of the response is non-empty before
calling `getTreeFromXml` on it. An example of an offending
command is using `s3cmd info` on a nonexistent object.
  • Loading branch information
kellymclaughlin committed Feb 29, 2012
1 parent 23d133a commit a845140
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion S3/Exceptions.py
Expand Up @@ -44,7 +44,7 @@ def __init__(self, response):
if response.has_key("headers"):
for header in response["headers"]:
debug("HttpHeader: %s: %s" % (header, response["headers"][header]))
if response.has_key("data"):
if response.has_key("data") and response["data"]:
tree = getTreeFromXml(response["data"])
error_node = tree
if not error_node.tag == "Error":
Expand Down

0 comments on commit a845140

Please sign in to comment.