[py3] bug.lp_save() crashes with TypeError: startswith first arg must be bytes or a tuple of bytes, not str

Bug #1414075 reported by Martin Pitt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lazr.restfulclient (Ubuntu)
Fix Released
Undecided
Dimitri John Ledkov

Bug Description

While porting Apport to python3-launchpadlib, I stumbled over the inability to call lp_save() on a bug object:

$ python3 /tmp/test.py
Traceback (most recent call last):
  File "/tmp/test.py", line 10, in <module>
    bug.lp_save()
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/resource.py", line 778, in lp_save
    URI(self.self_link), representation, headers)
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 475, in patch
    cached_etag = self._connection._getCachedHeader(str(url), 'etag')
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 188, in _getCachedHeader
    return self.cache._getCachedHeader(uri, header)
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 323, in _getCachedHeader
    if line.startswith(header_start):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

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).

Revision history for this message
Martin Pitt (pitti) wrote :
summary: - bug.lp_save() crashes with TypeError: startswith first arg must be bytes
- or a tuple of bytes, not str
+ [py3] bug.lp_save() crashes with TypeError: startswith first arg must be
+ bytes or a tuple of bytes, not str
Changed in lazr.restfulclient (Ubuntu):
assignee: nobody → Dimitri John Ledkov (xnox)
Changed in lazr.restfulclient (Ubuntu):
status: New → In Progress
Changed in lazr.restfulclient (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lazr.restfulclient - 0.13.4-4

---------------
lazr.restfulclient (0.13.4-4) experimental; urgency=medium

  * Decode headers before comparison (LP: #1414075)
  * Fix urllib unquote imports (LP: #1414055)

 -- Dimitri John Ledkov <email address hidden> Thu, 12 Feb 2015 23:40:09 +0000

Changed in lazr.restfulclient (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

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