Merge lp:~james-w/wadllib/fix-simplejson-unicode into lp:wadllib

Proposed by James Westby
Status: Merged
Approved by: Deryck Hodge
Approved revision: 11
Merged at revision: not available
Proposed branch: lp:~james-w/wadllib/fix-simplejson-unicode
Merge into: lp:wadllib
Diff against target: None lines
To merge this branch: bzr merge lp:~james-w/wadllib/fix-simplejson-unicode
Reviewer Review Type Date Requested Status
Leonard Richardson (community) Approve
Deryck Hodge (community) Approve
Review via email: mp+10180@code.launchpad.net
To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Hi,

Please see http://code.google.com/p/simplejson/issues/detail?id=40

This means that the output of simplejson.loads changes depending on
the version of simplejson, and whether the C speedups are in use,
unless you always pass in unicode.

This meant that the tests would fail on some systems, but also that
you couldn't rely on the output.

This change ensures that all parsed strings will be unicode, as the
tests assert.

Thanks,

James

Revision history for this message
Deryck Hodge (deryck) wrote :

Hi, James.

Thanks for the fix! It looks fine to me, but I'm asking Leonard to take a look as well.

Cheers,
deryck

review: Approve
Revision history for this message
Leonard Richardson (leonardr) wrote :

This looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/wadllib/README.txt'
2--- src/wadllib/README.txt 2009-07-09 16:56:54 +0000
3+++ src/wadllib/README.txt 2009-08-14 18:38:33 +0000
4@@ -312,7 +312,7 @@
5 'representation_needs_processing' argument.
6
7 >>> import simplejson
8- >>> processed_limi_data = simplejson.loads(limi_data)
9+ >>> processed_limi_data = simplejson.loads(unicode(limi_data))
10 >>> bound_limi = Resource(wadl, "http://api.launchpad.dev/beta/~limi",
11 ... "http://api.launchpad.dev/beta/#person", processed_limi_data,
12 ... "application/json", False)
13
14=== modified file 'src/wadllib/application.py'
15--- src/wadllib/application.py 2009-07-09 17:01:46 +0000
16+++ src/wadllib/application.py 2009-08-14 18:38:33 +0000
17@@ -280,7 +280,7 @@
18 if representation is not None:
19 if media_type == 'application/json':
20 if representation_needs_processing:
21- self.representation = simplejson.loads(representation)
22+ self.representation = simplejson.loads(unicode(representation))
23 else:
24 self.representation = representation
25 else:

Subscribers

People subscribed via source and target branches