Merge lp:~cjwatson/lazr.restful/py3-web-service-caller-bytes-url into lp:lazr.restful

Proposed by Colin Watson
Status: Merged
Merged at revision: 288
Proposed branch: lp:~cjwatson/lazr.restful/py3-web-service-caller-bytes-url
Merge into: lp:lazr.restful
Diff against target: 15 lines (+4/-1)
1 file modified
src/lazr/restful/testing/webservice.py (+4/-1)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/py3-web-service-caller-bytes-url
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+396623@code.launchpad.net

Commit message

Accept path_or_url as bytes in WebServiceCaller.__call__ on Python 3.

Description of the change

src/lazr/restful/example/base/tests/collection.txt asserted that this worked, and there's a reasonable point of view that URLs are fundamentally bytes. Make sure this keeps working.

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/lazr/restful/testing/webservice.py'
2--- src/lazr/restful/testing/webservice.py 2021-01-18 11:42:33 +0000
3+++ src/lazr/restful/testing/webservice.py 2021-01-21 00:15:56 +0000
4@@ -297,7 +297,10 @@
5
6 def __call__(self, path_or_url, method='GET', data=None, headers=None,
7 api_version=None):
8- path_or_url = str(path_or_url)
9+ if isinstance(path_or_url, (bytes, six.text_type)):
10+ path_or_url = six.ensure_str(path_or_url)
11+ else:
12+ path_or_url = str(path_or_url)
13 if path_or_url.startswith('/'):
14 api_version = api_version or self.default_api_version
15 full_url = '/'.join([api_version, path_or_url])

Subscribers

People subscribed via source and target branches