Skip to content

Instantly share code, notes, and snippets.

@daddz
Last active Aug 29, 2015
Embed
What would you like to do?
from requests_toolbelt import MultipartEncoderMonitor
fields_work = [(u'test', 'foo'), ('bar', u'baz'), ('baz', '')]
m_work = MultipartEncoderMonitor.from_fields(fields=fields_work)
fields_fail = [(u'test', u'')]
m_fail = MultipartEncoderMonitor.from_fields(fields=fields_fail)
Traceback (most recent call last):
File "fail.py", line 10, in <module>
m_fail = MultipartEncoderMonitor.from_fields(fields=fields_fail)
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 297, in from_fields
encoder = MultipartEncoder(fields, boundary, encoding)
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 89, in __init__
self._prepare_parts()
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 171, in _prepare_parts
self.parts = [Part.from_field(f, enc) for f in fields]
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 383, in from_field
body = coerce_data(field.data, encoding)
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 359, in coerce_data
return CustomBytesIO(data, encoding)
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 425, in __init__
super(CustomBytesIO, self).__init__(buffer)
TypeError: 'unicode' does not have the buffer interface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment