Skip to content

Commit 200ab22

Browse files
committed
handle byte/string issues with s3
1 parent 0bcb2d0 commit 200ab22

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

canopener/s3file.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __new__(
2525
aws_secret_access_key=None,
2626
):
2727
"""Opens a local copy of an S3 URL."""
28-
parse = urlparse.urlparse(filename)
28+
parse = urlparse(filename)
2929
if 'w' in mode:
3030
raise ValueError("can't write to S3")
3131
if parse.scheme != 's3':
@@ -37,8 +37,8 @@ def __new__(
3737
)
3838
bucket = conn.get_bucket(parse.netloc)
3939
key = bucket.get_key(parse.path)
40-
41-
local_file = tempfile.TemporaryFile()
40+
local_file = tempfile.TemporaryFile(mode=tempfilemode)
4241
key.get_contents_to_file(local_file)
4342
local_file.seek(0)
43+
return open(local_file, mode=mode)
4444
return local_file

0 commit comments

Comments
 (0)