Merge lp:~cjwatson/lazr.restful/remove-simplejson-workaround into lp:lazr.restful

Proposed by Colin Watson on 2018-11-15
Status: Merged
Merged at revision: 223
Proposed branch: lp:~cjwatson/lazr.restful/remove-simplejson-workaround
Merge into: lp:lazr.restful
Diff against target: 54 lines (+10/-8)
3 files modified
src/lazr/restful/NEWS.txt (+3/-0)
src/lazr/restful/docs/webservice-marshallers.txt (+4/-0)
src/lazr/restful/marshallers.py (+3/-8)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/remove-simplejson-workaround
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve on 2018-11-15
LAZR Developers 2018-11-15 Pending
Review via email: mp+358849@code.launchpad.net

Commit message

Fix interpretation of values from requests containing only whitespace.

Description of the change

The referenced simplejson bug was fixed in 2.1.0, which lazr.restful already requires.

To post a comment you must log in.
Natalia Bidart (nataliabidart) wrote :

15:33 < nessita> cjwatson, looks good to me, but of course you may need a lazr developer vote

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/lazr/restful/NEWS.txt'
--- src/lazr/restful/NEWS.txt 2018-10-01 08:55:53 +0000
+++ src/lazr/restful/NEWS.txt 2018-11-15 15:31:17 +0000
@@ -16,6 +16,9 @@
16Generate IEntry subinterfaces with field ordering matching that in the16Generate IEntry subinterfaces with field ordering matching that in the
17original interface.17original interface.
1818
19Fixed bug 1803564: Values from requests that contain only whitespace are now
20interpreted correctly.
21
190.20.1 (2018-02-21)220.20.1 (2018-02-21)
20===================23===================
2124
2225
=== modified file 'src/lazr/restful/docs/webservice-marshallers.txt'
--- src/lazr/restful/docs/webservice-marshallers.txt 2018-09-28 15:47:07 +0000
+++ src/lazr/restful/docs/webservice-marshallers.txt 2018-11-15 15:31:17 +0000
@@ -103,6 +103,10 @@
103 'False'103 'False'
104 >>> marshaller.marshall_from_request("")104 >>> marshaller.marshall_from_request("")
105 ''105 ''
106 >>> marshaller.marshall_from_request(' ')
107 ' '
108 >>> marshaller.marshall_from_request('\n')
109 '\n'
106 >>> marshaller.marshall_from_request(['value1', 'value2'])110 >>> marshaller.marshall_from_request(['value1', 'value2'])
107 ['value1', 'value2']111 ['value1', 'value2']
108112
109113
=== modified file 'src/lazr/restful/marshallers.py'
--- src/lazr/restful/marshallers.py 2016-02-17 01:07:21 +0000
+++ src/lazr/restful/marshallers.py 2018-11-15 15:31:17 +0000
@@ -156,18 +156,13 @@
156 v = value156 v = value
157 if isinstance(v, str):157 if isinstance(v, str):
158 v = v.decode('utf8') # assume utf8158 v = v.decode('utf8') # assume utf8
159 # XXX gary 2009-03-28159 elif not isinstance(v, unicode):
160 # The use of the enclosing brackets is a hack to work around160 v = unicode(v)
161 # simplejson bug 43:161 value = simplejson.loads(v)
162 # http://code.google.com/p/simplejson/issues/detail?id=43
163 v = simplejson.loads(u'[%s]' % (v,))
164 except (ValueError, TypeError):162 except (ValueError, TypeError):
165 # Pass the value as is. This saves client from having to encode163 # Pass the value as is. This saves client from having to encode
166 # strings.164 # strings.
167 pass165 pass
168 else:
169 # see comment about simplejson bug above
170 value = v[0]
171 if value is None:166 if value is None:
172 return None167 return None
173 return self._marshall_from_request(value)168 return self._marshall_from_request(value)

Subscribers

People subscribed via source and target branches