Boto 1.5b glitch, and workaround

Boto is a Python library for interacting with Amazon’s web services. I’ve used it in the past, and am currently using it for an ‘s3get’ implementation based on a simple example I found buried in a post on Patrick Altman’s blog.

While testing my code, I noticed I was getting import errors from boto/, because I didn’t have a module on my system named ‘hashlib’. Then I found an svn trunk commit that clued me in to the fact that I wasn’t supposed to have hashlib, because I was running a pre-2.5 version of Python. They had put in a fix for pre-2.5 users, but somehow it wasn’t being obeyed.

Then I noticed that the import errors weren’t from, where the fix was committed, but from, which was explicitly importing the module itself. Closer inspection revealed that it was also importing, which itself imports hashlib. I commented out the explicit import in (and, later, in boto/s3/, and stopped getting import errors.

If you’re still having issues with Patrick’s code, it’s probably because you need to change this line:

if name == 'main':

To this:

if __name__ == '__main__':