project_release.add_file can't upload binary data

Bug #408605 reported by Michael Hofmann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
launchpadlib
New
Undecided
Unassigned

Bug Description

If I try to add a binary file to a project release

f=release.add_file(filename='dummy', file_content='\xff', content_type='application/octet-stream')

I get
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/dist-packages/launchpadlib/resource.py", line 337, in __call__
    args[key] = simplejson.dumps(value, cls=DatetimeJSONEncoder)
  File "/var/lib/python-support/python2.6/simplejson/__init__.py", line 243, in dumps
    **kw).encode(obj)
  File "/var/lib/python-support/python2.6/simplejson/encoder.py", line 360, in encode
    return encode_basestring_ascii(o)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0: unexpected code byte

because json cannot encode binary data (unless a special encoding such as base64 is used). Is there a way around this or am I doing something completely wrong?

Python 2.6.2 on a default jaunty system:
ii python 2.6.2-0ubuntu1
ii python-launchpadlib 0.2~bzr35-0ubuntu1
ii python-simplejson 1.9.2-1build1
ii python-wadllib 0.1~bzr7-0ubuntu4

Michael Hofmann (mh21)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.