TypeError crash if credentials are expired and needs to re-login [py3]

Bug #1422249 reported by Martin Pitt on 2015-02-16
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-launchpadlib (Ubuntu)
Undecided
Colin Watson

Bug Description

If my credentials timed out (quite usual on staging), lplib usually spawns the login procedure in the browser:

$ python -c "from launchpadlib.launchpad import Launchpad; lp = Launchpad.login_with('apport-collect', 'staging', allow_access_levels=['WRITE_PRIVATE'], credentials_file='.cache/apport/launchpad.credentials.staging'); print(lp.projects['apport'])"
The authorization page:
 (https://staging.launchpad.net/+authorize-token?oauth_token=k3d8MmR59rTggzqnLvtL&allow_permission=DESKTOP_INTEGRATION)
should be opening in your browser. Use your browser to authorize
this program to access Launchpad on your behalf.
Waiting to hear from Launchpad about your decision...
[...]

But it crashes with python 3:

$ python3 -c "from launchpadlib.launchpad import Launchpad; lp = Launchpad.login_with('apport-collect', 'staging', allow_access_levels=['WRITE_PRIVATE'], credentials_file='.cache/apport/launchpad.credentials.staging'); print(lp.projects['apport'])"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/resource.py", line 1001, in __getitem__
    shim_resource._ensure_representation()
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/resource.py", line 382, in _ensure_representation
    representation = self._root._browser.get(self._wadl_resource)
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 436, in get
    response, content = self._request(url, extra_headers=headers)
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 387, in _request
    str(url), method=method, body=data, headers=headers)
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 357, 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 132, in _request
    return self.retry_on_bad_token(response, content, *args)
  File "/usr/lib/python3/dist-packages/launchpadlib/launchpad.py", line 139, in retry_on_bad_token
    if (self._bad_oauth_token(response, content)
  File "/usr/lib/python3/dist-packages/launchpadlib/launchpad.py", line 125, in _bad_oauth_token
    (content.startswith("Expired token")
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

ProblemType: Bug
DistroRelease: Ubuntu 15.04
Package: python3-launchpadlib 1.10.3-1
ProcVersionSignature: Ubuntu 3.18.0-13.14-generic 3.18.5
Uname: Linux 3.18.0-13-generic x86_64
ApportVersion: 2.16.1-0ubuntu2
Architecture: amd64
CurrentDesktop: Unity
Date: Mon Feb 16 07:24:01 2015
EcryptfsInUse: Yes
InstallationDate: Installed on 2014-11-20 (87 days ago)
InstallationMedia: Ubuntu 15.04 "Vivid Vervet" - Alpha amd64 (20141119)
PackageArchitecture: all
SourcePackage: python-launchpadlib
UpgradeStatus: No upgrade log present (probably fresh install)

Martin Pitt (pitti) wrote :
Changed in python-launchpadlib (Ubuntu):
assignee: nobody → Dimitri John Ledkov (xnox)
Martin Pitt (pitti) on 2015-02-16
summary: - TypeError crash if credentials are expired and needs to re-login
+ TypeError crash if credentials are expired and needs to re-login [py3]
Changed in python-launchpadlib (Ubuntu):
assignee: Dimitri John Ledkov (xnox) → Colin Watson (cjwatson)
Colin Watson (cjwatson) wrote :

This was also bug 1471894, and so is fixed in launchpadlib 1.10.4, which is in >= zesty.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers