lericson / simples3

Simple, quick Amazon AWS S3 interface in Python
BSD 2-Clause "Simplified" License
96 stars 36 forks source link

Fixed #10 — S3Bucket.listdir() method raise UnboundLocalError sometimes #9

Closed dahlia closed 12 years ago

dahlia commented 12 years ago

S3Bucket.listdir() method raised UnboundLocalError when the result list is empty. This patch fixes the bug. You can reproduce the bug by running following code:

from simples3.bucket import S3Bucket

S3_BUCKET_NAME = '...'
S3_ACCESS_KEY = '...'
S3_SECRET_KEY = '...'

bucket = S3Bucket(S3_BUCKET_NAME, S3_ACCESS_KEY, S3_SECRET_KEY)

# The above code works well both.
for x in bucket.listdir(prefix='existing-prefix'):
    print x

# The above code works only after this patch.
for x in bucket.listdir(prefix='not-existing-prefix'):
    print x

This bug fix has done by Hyunjun Kim, an employee of my company. Thank you!

lericson commented 12 years ago

Fixed in 56cb4aac30bfca9c1f8872656c80910d19551e73