urllib.urlencode() does not exist for python3

Bug #1425609 reported by Martin Pitt on 2015-02-25
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
lazr.restfulclient
High
Colin Watson
lazr.restfulclient (Ubuntu)
High
Colin Watson

Bug Description

This is similar to bug 1414055, but now for urlencode:

Traceback (most recent call last):
  File "apport/crashdb_impl/launchpad.py", line 1950, in test_marking_python_task_mangle
    t = b.bug_tasks[0]
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/resource.py", line 853, in __getitem__
    found_slice = self._get_slice(slice(key, key + 1))
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/resource.py", line 903, in _get_slice
    self._wadl_resource.url, 'ws.start', start)
  File "/usr/lib/python3/dist-packages/lazr/restfulclient/resource.py", line 976, in _with_url_query_variable_set
    uri.query = urllib.urlencode(params, True)
AttributeError: 'module' object has no attribute 'urlencode'

I suggest something like

if sys.version_info.major == 2:
    from urllib import urlencode
else:
    from urllib.parse import urlencode

and use urlencode() without namespace.

Related branches

Martin Pitt (pitti) on 2015-02-25
Changed in lazr.restfulclient (Ubuntu):
assignee: nobody → Dimitri John Ledkov (xnox)
Changed in lazr.restfulclient (Ubuntu):
status: New → Fix Committed
Changed in lazr.restfulclient (Ubuntu):
assignee: Dimitri John Ledkov (xnox) → Colin Watson (cjwatson)
Colin Watson (cjwatson) on 2016-04-19
Changed in lazr.restfulclient:
assignee: nobody → Colin Watson (cjwatson)
status: New → Fix Committed
importance: Undecided → High
Changed in lazr.restfulclient (Ubuntu):
importance: Undecided → High
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lazr.restfulclient - 0.13.4-5ubuntu1

---------------
lazr.restfulclient (0.13.4-5ubuntu1) xenial; urgency=medium

  * Cherry-pick from upstream:
    - Update imports for urlencode (thanks, Dimitri John Ledkov;
      LP: #1425609).

 -- Colin Watson <email address hidden> Tue, 19 Apr 2016 10:25:38 +0100

Changed in lazr.restfulclient (Ubuntu):
status: Fix Committed → Fix Released
Colin Watson (cjwatson) wrote :

Fixed in 0.13.5.

Changed in lazr.restfulclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers