[Bug 1422249] Re: TypeError crash if credentials are expired and needs to re-login

Dimitri John Ledkov launchpad at surgut.co.uk
Mon Feb 16 06:27:02 UTC 2015


** Changed in: python-launchpadlib (Ubuntu)
     Assignee: (unassigned) => Dimitri John Ledkov (xnox)

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

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

Status in python-launchpadlib package in Ubuntu:
  New

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)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python-launchpadlib/+bug/1422249/+subscriptions



More information about the foundations-bugs mailing list