Merge lp:~cjwatson/lazr.restful/py3-encode-unicode into lp:lazr.restful

Proposed by Colin Watson
Status: Merged
Merged at revision: 281
Proposed branch: lp:~cjwatson/lazr.restful/py3-encode-unicode
Merge into: lp:lazr.restful
Diff against target: 34 lines (+5/-1)
2 files modified
NEWS.rst (+3/-0)
src/lazr/restful/testing/helpers.py (+2/-1)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/py3-encode-unicode
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+396619@code.launchpad.net

Commit message

Make encode_unicode return str on Python 3.

Description of the change

It's used in doctests, so returning bytes works much less well.

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS.rst'
2--- NEWS.rst 2021-01-20 11:23:16 +0000
3+++ NEWS.rst 2021-01-20 23:42:29 +0000
4@@ -18,6 +18,9 @@
5 ``lazr.restful.testing.webservice.pprint_collection`` recurse into lists in
6 order to print text string representations in the Python 3 style.
7
8+Make ``lazr.restful.testing.helpers.encode_unicode`` return ``str`` on
9+Python 3.
10+
11 0.23.0 (2020-09-28)
12 ===================
13
14
15=== modified file 'src/lazr/restful/testing/helpers.py'
16--- src/lazr/restful/testing/helpers.py 2020-07-22 22:28:49 +0000
17+++ src/lazr/restful/testing/helpers.py 2021-01-20 23:42:29 +0000
18@@ -3,6 +3,7 @@
19 import sys
20 from types import ModuleType
21
22+import six
23 from zope.configuration import xmlconfig
24 from zope.interface import implementer
25
26@@ -64,7 +65,7 @@
27
28 :param unicode_string: A Unicode string.
29 """
30- return unicode_string.encode("ascii", "backslashreplace")
31+ return six.ensure_str(unicode_string.encode("ascii", "backslashreplace"))
32
33
34 @implementer(IWebServiceConfiguration)

Subscribers

People subscribed via source and target branches