[Bug 1422249] [NEW] TypeError crash if credentials are expired and needs to re-login [py3]
Martin Pitt
martin.pitt at ubuntu.com
Mon Feb 16 06:25:50 UTC 2015
Public bug reported:
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)
** Affects: python-launchpadlib (Ubuntu)
Importance: Undecided
Assignee: Dimitri John Ledkov (xnox)
Status: New
** Tags: amd64 apport-bug vivid
--
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