You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.
Often we use a SpooledTemporaryFile to write data to SL object storage. Previously we were using Python 2.7.2 and this worked fine. After updating to Python 2.7.9 we were running into an issue with this scenario where we would get an exception:
TypeError: expected string or buffer
File "python2.7/site-packages/object_storage/storage_object.py", line 349, in send
File "python2.7/mimetypes.py", line 291, in guess_type
File "python2.7/mimetypes.py", line 114, in guess_type
File "python2.7/urllib.py", line 1080, in splittype
It turns out in Python 2.7.4 a name attribute was added to SpooledTemporaryFile which has a value of None. (See http://bugs.python.org/issue10355) That breaks this code in send():
if not content_type:
_type = None
if hasattr(data, 'name'):
_type = mimetypes.guess_type(data.name)[0]
content_type = (_type or
mimetypes.guess_type(self.name)[0] or
'application/octet-stream')
The issue can be fixed by changing the hasattr line:
if not content_type:
_type = None
if hasattr(data, 'name') and data.name:
_type = mimetypes.guess_type(data.name)[0]
content_type = (_type or
mimetypes.guess_type(self.name)[0] or
'application/octet-stream')
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Often we use a
SpooledTemporaryFile
to write data to SL object storage. Previously we were using Python 2.7.2 and this worked fine. After updating to Python 2.7.9 we were running into an issue with this scenario where we would get an exception:It turns out in Python 2.7.4 a
name
attribute was added toSpooledTemporaryFile
which has a value ofNone
. (See http://bugs.python.org/issue10355) That breaks this code insend()
:The issue can be fixed by changing the
hasattr
line:The text was updated successfully, but these errors were encountered: