python3 resource.py: no attribute urlencode error
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
launchpadlib |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
I am getting a trace back on
def _with_url_
"""A helper method to set a query variable in a URL."""
uri = URI(url)
if uri.query is None:
params = {}
else:
params = parse_qs(uri.query)
uri.query = urllib.
return str(uri)
File "/usr/lib/
line 853, in __getitem__
found_slice = self._get_
File "/usr/lib/
line 903, in _get_slice
self.
File "/usr/lib/
line 976, in _with_url_
uri.query = urllib.
AttributeError: 'module' object has no attribute 'urlencode'
I am wondering whether it is trying to encode a string when python3 has everything encoded by default - thus the encode function is now invalid.
No, this is caused by the urllib module changing API between python2 and python3. The fix is most likely that lazr.restfulclient needs to use six.moves in order to safely import urllib regardless of python version being used.
For now, you can workaround this issue like so:
from urllib.parse import urlencode urllib. urlencode = urlencode
from lazr.restfulclient import resource
resource.