Invalid Syntax When Using or Installing S3Cmd Tools

I installed the s3 tools on a new machine that was spun up for a testing environment. I was quickly greeted with an ugly error message.

</p>

 utc = datetime.datetime(*dateS3toPython(s3timestamp[0:6],tzinfo=pytz.timezone(‘UTC’))  ^
SyntaxError: invalid syntax

</p>

Not a very helpful error if you're new to Python. I'm not 100% sure what the problem is here, but it appears that Python version 2.5.2 (and older) have a problem with list expansion combined with a keyword argument.

</p>

Here's some quick dummy code I put together to illustrate.

</p>

Python 2.5.2

</p>

def test(*args, **kwargs):
print "Received Args"
print "Received Kwargs"</p>

>>> arg=(1,2,3,4)
>>> test(*arg, test='bar')
File "", line 1
test(*arg, test='bar')
^
SyntaxError: invalid syntax
>>> test(1,2,3,4,test='bar')
Received Args
Received Kwargs
</code></pre></p>

But running this same code on Python 2.6.8 (which is in the Redhat Repos) doesn't produce the problem at all.

</p>

So the easy fix is to upgrade your version of Python. I've reported the bug to the S3cmd team to address. My guess is they'll just require a newer version of Python. Their current version test only looks for 2.4 or better. Which is probably out date.

</p>

comments powered by Disqus