[Bug 1414063] Re: [py3] bug.addAttachment() causes UnicodeEncodeError with binary data

Dimitri John Ledkov launchpad at surgut.co.uk
Sat Jan 31 11:40:34 UTC 2015


** Changed in: lazr.restfulclient (Ubuntu)
       Status: New => In Progress

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to lazr.restfulclient in Ubuntu.
https://bugs.launchpad.net/bugs/1414063

Title:
  [py3] bug.addAttachment() causes UnicodeEncodeError with binary data

Status in lazr.restfulclient package in Ubuntu:
  In Progress

Bug description:
  While porting Apport to python3-launchpadlib, I stumbled over the
  inability to attach binary data to a bug:

  $ python3 /tmp/test.py
  Traceback (most recent call last):
    File "/tmp/test.py", line 15, in <module>
      is_patch=False)
    File "/usr/lib/python3/dist-packages/lazr/restfulclient/resource.py", line 609, in __call__
      extra_headers=extra_headers)
    File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 385, in _request
      str(url), method=method, body=data, headers=headers)
    File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 355, in _request_and_retry
      url, method=method, body=body, headers=headers)
    File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 1291, in request
      (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
    File "/usr/lib/python3/dist-packages/launchpadlib/launchpad.py", line 131, in _request
      LaunchpadOAuthAwareHttp, self)._request(*args)
    File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 183, in _request
      redirections, cachekey)
    File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 1041, in _request
      (response, content) = self._conn_request(conn, request_uri, method, body, headers)
    File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 966, in _conn_request
      conn.request(method, request_uri, body, headers)
    File "/usr/lib/python3.4/http/client.py", line 1090, in request
      self._send_request(method, url, body, headers)
    File "/usr/lib/python3.4/http/client.py", line 1127, in _send_request
      body = body.encode('iso-8859-1')
  UnicodeEncodeError: 'latin-1' codec can't encode characters in position 1217-1218: ordinal not in range(256)

  When I call the same with python 2, it works fine. Note that this is a
  write operation, so this needs to use login_with() and credentials. So
  you might want to change the credentials_file= argument in the
  reproducer or drop it completely (then you'll have to log in every
  time you run the reproducer).

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lazr.restfulclient/+bug/1414063/+subscriptions



More information about the foundations-bugs mailing list