Merge lp:~cjwatson/launchpad/simplejson-3.8.2 into lp:launchpad

Proposed by Colin Watson on 2016-06-06
Status: Merged
Merged at revision: 18095
Proposed branch: lp:~cjwatson/launchpad/simplejson-3.8.2
Merge into: lp:launchpad
Diff against target: 42 lines (+16/-1)
2 files modified
lib/lp/code/model/tests/test_githosting.py (+15/-0)
versions.cfg (+1/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/simplejson-3.8.2
Reviewer Review Type Date Requested Status
William Grant code 2016-06-06 Approve on 2016-06-06
Review via email: mp+296539@code.launchpad.net

Commit message

Upgrade to simplejson 3.8.2, fixing decoding of Git diffs involving non-UTF-8 text that decodes to unpaired surrogates when treated as UTF-8.

Description of the change

Upgrade to simplejson 3.8.2, fixing decoding of Git diffs involving non-UTF-8 text that decodes to unpaired surrogates when treated as UTF-8.

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/model/tests/test_githosting.py'
2--- lib/lp/code/model/tests/test_githosting.py 2016-05-19 14:54:33 +0000
3+++ lib/lp/code/model/tests/test_githosting.py 2016-06-06 11:17:56 +0000
4@@ -1,3 +1,7 @@
5+# -*- coding: utf-8 -*-
6+# NOTE: The first line above must stay first; do not move the copyright
7+# notice to the top. See http://www.python.org/dev/peps/pep-0263/.
8+#
9 # Copyright 2016 Canonical Ltd. This software is licensed under the
10 # GNU Affero General Public License version 3 (see the file LICENSE).
11
12@@ -226,6 +230,17 @@
13 self.assertRequest(
14 "repo/123/compare-merge/a:b?sha1_prerequisite=c", method="GET")
15
16+ def test_getMergeDiff_unpaired_surrogate(self):
17+ # pygit2 tries to decode the diff as UTF-8 with errors="replace".
18+ # In some cases this can result in unpaired surrogates, which older
19+ # versions of json/simplejson don't like.
20+ content = json.dumps(
21+ {"patch": "卷。".encode("GBK").decode("UTF-8", errors="replace")})
22+ with self.mockRequests(content=content):
23+ diff = self.client.getMergeDiff("123", "a", "b")
24+ self.assertEqual({"patch": "\uFFFD\uD863"}, diff)
25+ self.assertRequest("repo/123/compare-merge/a:b", method="GET")
26+
27 def test_getMergeDiff_failure(self):
28 with self.mockRequests(status_code=400, content=b"Bad request"):
29 self.assertRaisesWithContent(
30
31=== modified file 'versions.cfg'
32--- versions.cfg 2016-05-24 04:45:38 +0000
33+++ versions.cfg 2016-06-06 11:17:56 +0000
34@@ -125,7 +125,7 @@
35 s4 = 0.1.2
36 setproctitle = 1.1.7
37 setuptools-git = 1.0
38-simplejson = 3.1.3
39+simplejson = 3.8.2
40 SimpleTAL = 4.3
41 six = 1.9.0
42 soupmatchers = 0.2