Skip to content

Commit 9eb94f9

Browse files
author
Razvan Nesiu
committed
Update to python 3 syntax (changed syntax for file: StringIO -> BytesIO)
1 parent e55dc72 commit 9eb94f9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

django_google_storage/file.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding=utf-8
22
from django.core.files.base import File
3-
from io import StringIO
3+
from io import BytesIO
44

55
class GSBotoStorageFile(File):
66
def __init__(self, name, mode, storage):
@@ -18,20 +18,20 @@ def size(self):
1818
@property
1919
def file(self):
2020
if self._file is None:
21-
self._file = StringIO()
22-
if 'r' in self._mode:
21+
self._file = BytesIO()
22+
if 'rb' in self._mode:
2323
self._is_dirty = False
2424
self.key.get_contents_to_file(self._file)
2525
self._file.seek(0)
2626
return self._file
2727

2828
def read(self, *args, **kwargs):
29-
if 'r' not in self._mode:
29+
if 'rb' not in self._mode:
3030
raise AttributeError("File was not opened in read mode.")
3131
return super(GSBotoStorageFile, self).read(*args, **kwargs)
3232

3333
def write(self, *args, **kwargs):
34-
if 'w' not in self._mode:
34+
if 'wb' not in self._mode:
3535
raise AttributeError("File was opened for read-only access.")
3636
self._is_dirty = True
3737
return super(GSBotoStorageFile, self).write(*args, **kwargs)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name='django-google-storage-updated',
6-
version='0.5.3',
6+
version='0.5.4',
77
packages=['django_google_storage', ],
88
author='Maxim Smirnoff',
99
author_email='[email protected]',

0 commit comments

Comments
 (0)