Merge lp:~cjwatson/launchpadlib/py38-access-token into lp:launchpadlib

Proposed by Colin Watson
Status: Merged
Merged at revision: 176
Proposed branch: lp:~cjwatson/launchpadlib/py38-access-token
Merge into: lp:launchpadlib
Diff against target: 86 lines (+27/-2)
4 files modified
NEWS.rst (+4/-0)
setup.py (+1/-0)
src/launchpadlib/credentials.py (+3/-2)
src/launchpadlib/tests/test_credential_store.py (+19/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpadlib/py38-access-token
Reviewer Review Type Date Requested Status
Tom Wardill (community) Approve
Review via email: mp+378523@code.launchpad.net

Commit message

Fix AccessToken.from_string crash on Python 3.8.

To post a comment you must log in.
Revision history for this message
Tom Wardill (twom) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS.rst'
--- NEWS.rst 2019-11-28 00:07:07 +0000
+++ NEWS.rst 2020-02-04 14:29:20 +0000
@@ -2,6 +2,10 @@
2NEWS for launchpadlib2NEWS for launchpadlib
3=====================3=====================
44
51.10.10
6=======
7- Fix AccessToken.from_string crash on Python 3.8. [bug=1861873]
8
51.10.9 (2019-11-28)91.10.9 (2019-11-28)
6===================10===================
7- Explicitly install version.txt; launchpadlib requires it.11- Explicitly install version.txt; launchpadlib requires it.
812
=== modified file 'setup.py'
--- setup.py 2019-11-27 19:40:17 +0000
+++ setup.py 2020-02-04 14:29:20 +0000
@@ -47,6 +47,7 @@
47 'lazr.restfulclient>=0.9.19',47 'lazr.restfulclient>=0.9.19',
48 'lazr.uri',48 'lazr.uri',
49 'setuptools',49 'setuptools',
50 'six',
50 'testresources',51 'testresources',
51 'wadllib',52 'wadllib',
52 ]53 ]
5354
=== modified file 'src/launchpadlib/credentials.py'
--- src/launchpadlib/credentials.py 2018-03-07 10:42:12 +0000
+++ src/launchpadlib/credentials.py 2020-02-04 14:29:20 +0000
@@ -29,7 +29,6 @@
29 'Credentials',29 'Credentials',
30 ]30 ]
3131
32import cgi
33try:32try:
34 from cStringIO import StringIO33 from cStringIO import StringIO
35except ImportError:34except ImportError:
@@ -60,6 +59,8 @@
60except ImportError:59except ImportError:
61 import simplejson as json60 import simplejson as json
6261
62from six.moves.urllib.parse import parse_qs
63
63if bytes is str:64if bytes is str:
64 # Python 265 # Python 2
65 unicode_type = unicode66 unicode_type = unicode
@@ -248,7 +249,7 @@
248 """Create and return a new `AccessToken` from the given string."""249 """Create and return a new `AccessToken` from the given string."""
249 if not isinstance(query_string, unicode_type):250 if not isinstance(query_string, unicode_type):
250 query_string = query_string.decode('utf-8')251 query_string = query_string.decode('utf-8')
251 params = cgi.parse_qs(query_string, keep_blank_values=False)252 params = parse_qs(query_string, keep_blank_values=False)
252 key = params['oauth_token']253 key = params['oauth_token']
253 assert len(key) == 1, (254 assert len(key) == 1, (
254 "Query string must have exactly one oauth_token.")255 "Query string must have exactly one oauth_token.")
255256
=== modified file 'src/launchpadlib/tests/test_credential_store.py'
--- src/launchpadlib/tests/test_credential_store.py 2014-07-14 20:29:51 +0000
+++ src/launchpadlib/tests/test_credential_store.py 2020-02-04 14:29:20 +0000
@@ -41,6 +41,25 @@
41)41)
4242
4343
44class TestAccessToken(unittest.TestCase):
45 """Tests for the AccessToken class."""
46
47 def test_from_string(self):
48 access_token = AccessToken.from_string(
49 "oauth_token_secret=secret%3Dpassword&oauth_token=lock%26key")
50 self.assertEqual("lock&key", access_token.key)
51 self.assertEqual("secret=password", access_token.secret)
52 self.assertIsNone(access_token.context)
53
54 def test_from_string_with_context(self):
55 access_token = AccessToken.from_string(
56 "oauth_token_secret=secret%3Dpassword&oauth_token=lock%26key&"
57 "lp.context=firefox")
58 self.assertEqual("lock&key", access_token.key)
59 self.assertEqual("secret=password", access_token.secret)
60 self.assertEqual("firefox", access_token.context)
61
62
44class CredentialStoreTestCase(unittest.TestCase):63class CredentialStoreTestCase(unittest.TestCase):
4564
46 def make_credential(self, consumer_key):65 def make_credential(self, consumer_key):

Subscribers

People subscribed via source and target branches