Browse files

Handle empty return bodies when processing S3 errors.

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...
1 parent 23d133a commit a845140fd7f3dc0301299faa376e1fb750f7ec4e @kellymclaughlin kellymclaughlin committed Feb 29, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 S3/
@@ -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":

0 comments on commit a845140

Please sign in to comment.