Skip to content

Commit

Permalink
Fix py3 s3 prefix decoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
spulec committed Mar 16, 2017
1 parent e25d149 commit 446843e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions moto/s3/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def _bucket_response_get(self, bucket_name, querystring, headers):

bucket = self.backend.get_bucket(bucket_name)
prefix = querystring.get('prefix', [None])[0]
if prefix:
if prefix and isinstance(prefix, six.binary_type):
prefix = prefix.decode("utf-8")
delimiter = querystring.get('delimiter', [None])[0]
result_keys, result_folders = self.backend.prefix_query(
Expand All @@ -252,7 +252,7 @@ def _handle_list_objects_v2(self, bucket_name, querystring):
bucket = self.backend.get_bucket(bucket_name)

prefix = querystring.get('prefix', [None])[0]
if prefix:
if prefix and isinstance(prefix, six.binary_type):
prefix = prefix.decode("utf-8")
delimiter = querystring.get('delimiter', [None])[0]
result_keys, result_folders = self.backend.prefix_query(
Expand Down Expand Up @@ -282,7 +282,7 @@ def _handle_list_objects_v2(self, bucket_name, querystring):

return template.render(
bucket=bucket,
prefix=prefix or b'',
prefix=prefix or '',
delimiter=delimiter,
result_keys=result_keys,
result_folders=result_folders,
Expand Down

0 comments on commit 446843e

Please sign in to comment.