Merge lp:~cjwatson/loggerhead/remove-simplejson into lp:loggerhead

Proposed by Colin Watson
Status: Merged
Merged at revision: 505
Proposed branch: lp:~cjwatson/loggerhead/remove-simplejson
Merge into: lp:loggerhead
Diff against target: 229 lines (+24/-23)
12 files modified
.travis.yml (+1/-1)
NEWS (+3/-0)
byov.conf (+1/-1)
docs/index.rst (+0/-4)
loggerhead/controllers/__init__.py (+4/-3)
loggerhead/controllers/changelog_ui.py (+2/-2)
loggerhead/controllers/revision_ui.py (+4/-4)
loggerhead/load_test.py (+4/-2)
loggerhead/templatefunctions.py (+0/-3)
loggerhead/tests/test_simple.py (+2/-2)
loggerhead/util.py (+2/-0)
setup.py (+1/-1)
To merge this branch: bzr merge lp:~cjwatson/loggerhead/remove-simplejson
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+387063@code.launchpad.net

Commit message

Drop dependency on simplejson.

Description of the change

The standard library's json module in Python >= 2.6 will do fine.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.travis.yml'
2--- .travis.yml 2020-06-08 10:03:32 +0000
3+++ .travis.yml 2020-07-08 17:24:49 +0000
4@@ -22,7 +22,7 @@
5 install:
6 - sudo apt install subunit adduser libjs-jquery
7 - travis_retry pip install -U setuptools
8- - travis_retry pip install -U pip coverage codecov flake8 testtools configobj cython testscenarios six docutils python-subunit dulwich bzr+lp:brz pygments simplejson paste http://www.owlfish.com/software/simpleTAL/downloads/SimpleTAL-$TAL_VERSION.tar.gz bleach
9+ - travis_retry pip install -U pip coverage codecov flake8 testtools configobj cython testscenarios six docutils python-subunit dulwich bzr+lp:brz pygments paste http://www.owlfish.com/software/simpleTAL/downloads/SimpleTAL-$TAL_VERSION.tar.gz bleach
10
11 after_success:
12 - codecov
13
14=== modified file 'NEWS'
15--- NEWS 2019-09-19 08:10:36 +0000
16+++ NEWS 2020-07-08 17:24:49 +0000
17@@ -36,6 +36,9 @@
18 - Set line-height on <pre> elements in file views, fixing misaligned
19 line numbers in some browsers. (Colin Watson)
20
21+ - Drop dependency on simplejson in favour of the standard library's json
22+ module in Python >= 2.6. (Colin Watson)
23+
24 1.18.2 [12Sep2012]
25 ------------------
26
27
28=== modified file 'byov.conf'
29--- byov.conf 2020-06-04 19:43:36 +0000
30+++ byov.conf 2020-07-08 17:24:49 +0000
31@@ -11,7 +11,7 @@
32 [loggerhead]
33 vm.release = xenial
34 brz.build_deps = gcc, debhelper, python, python-all-dev, python3-all-dev, python-configobj, python3-configobj, python-docutils, python3-docutils, python-paramiko, python3-paramiko, python-subunit, python3-subunit, python-testtools, python3-testtools, subunit, cython, cython3, python-fastimport, python-dulwich, python-six, python3-six
35-loggerhead.build_deps = python-setuptools, python3-setuptools, libjs-jquery, python-docutils, python3-docutils, python-pygments, python3-pygments, python-simplejson, python3-simplejson, python-paste, python3-paste, python-pastedeploy, python3-pastedeploy, python-simpletal, python-bleach, python3-bleach
36+loggerhead.build_deps = python-setuptools, python3-setuptools, libjs-jquery, python-docutils, python3-docutils, python-pygments, python3-pygments, python-paste, python3-paste, python-pastedeploy, python3-pastedeploy, python-simpletal, python-bleach, python3-bleach
37 loggerhead.test_deps = python3-fixtures, python-fixtures
38 vm.packages = {brz.build_deps}, {loggerhead.build_deps}, {loggerhead.test_deps}, bzr, python-junitxml, python3-pip
39 brz.branch = (bzr branch lp:brz ../brz-trunk)
40
41=== modified file 'docs/index.rst'
42--- docs/index.rst 2019-09-18 16:49:18 +0000
43+++ docs/index.rst 2020-07-08 17:24:49 +0000
44@@ -15,8 +15,6 @@
45
46 - SimpleTAL for templating.
47
48-- simplejson for producing JSON data.
49-
50 - Paste for the server. (You need version 1.2 or newer of Paste).
51
52 - Paste Deploy (optional, needed when proxying through Apache).
53@@ -30,7 +28,6 @@
54 .. code-block:: sh
55
56 $ sudo apt-get install python-simpletal
57- $ sudo apt-get install python-simplejson
58 $ sudo apt-get install python-paste
59 $ sudo apt-get install python-pastedeploy
60 $ sudo apt-get install python-flup
61@@ -43,7 +40,6 @@
62 $ easy_install \
63 -f http://www.owlfish.com/software/simpleTAL/py2compatible/download.html \
64 SimpleTAL
65- $ easy_install simplejson
66 $ easy_install Paste
67 $ easy_install PasteDeploy
68 $ easy_install flup
69
70=== modified file 'loggerhead/controllers/__init__.py'
71--- loggerhead/controllers/__init__.py 2018-10-20 15:02:08 +0000
72+++ loggerhead/controllers/__init__.py 2020-07-08 17:24:49 +0000
73@@ -17,9 +17,10 @@
74 # along with this program; if not, write to the Free Software
75 # Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
76
77+import json
78+import time
79+
80 import breezy.errors
81-import simplejson
82-import time
83
84 from breezy import osutils
85
86@@ -122,7 +123,7 @@
87 z = time.time()
88 w = BufferingWriter(writer, 8192)
89 if environ.get('loggerhead.as_json'):
90- w.write(simplejson.dumps(values,
91+ w.write(json.dumps(values,
92 default=util.convert_to_json_ready).encode('utf-8'))
93 else:
94 self.add_template_values(values)
95
96=== modified file 'loggerhead/controllers/changelog_ui.py'
97--- loggerhead/controllers/changelog_ui.py 2018-10-20 16:06:44 +0000
98+++ loggerhead/controllers/changelog_ui.py 2020-07-08 17:24:49 +0000
99@@ -18,7 +18,7 @@
100 # Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
101 #
102
103-import simplejson
104+import json
105
106 from paste.httpexceptions import HTTPServerError
107
108@@ -99,7 +99,7 @@
109 'branch': self._branch,
110 'changes': changes,
111 'show_tag_col': show_tag_col,
112- 'data': simplejson.dumps(data),
113+ 'data': json.dumps(data),
114 'util': util,
115 'history': history,
116 'revid': revid,
117
118=== modified file 'loggerhead/controllers/revision_ui.py'
119--- loggerhead/controllers/revision_ui.py 2020-01-19 20:09:08 +0000
120+++ loggerhead/controllers/revision_ui.py 2020-07-08 17:24:49 +0000
121@@ -17,7 +17,7 @@
122 # Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
123 #
124
125-import simplejson
126+import json
127
128 from paste.httpexceptions import HTTPServerError
129
130@@ -152,9 +152,9 @@
131
132 values.update({
133 'history': self._history,
134- 'link_data': simplejson.dumps(link_data),
135- 'json_specific_path': simplejson.dumps(path),
136- 'path_to_id': simplejson.dumps(path_to_id),
137+ 'link_data': json.dumps(link_data),
138+ 'json_specific_path': json.dumps(path),
139+ 'path_to_id': json.dumps(path_to_id),
140 'directory_breadcrumbs': directory_breadcrumbs,
141 'navigation': navigation,
142 'remember': remember,
143
144=== modified file 'loggerhead/load_test.py'
145--- loggerhead/load_test.py 2020-05-06 19:18:04 +0000
146+++ loggerhead/load_test.py 2020-07-08 17:24:49 +0000
147@@ -70,7 +70,7 @@
148 except ImportError: # Python < 3
149 from Queue import Queue, Empty
150
151-import simplejson
152+import json
153
154 from breezy import (
155 errors,
156@@ -157,7 +157,9 @@
157 @classmethod
158 def parse(cls, content):
159 script = cls()
160- json_dict = simplejson.loads(content)
161+ if isinstance(content, bytes):
162+ content = content.decode('UTF-8')
163+ json_dict = json.loads(content)
164 if 'parameters' not in json_dict:
165 raise ValueError('Missing "parameters" section')
166 if 'requests' not in json_dict:
167
168=== modified file 'loggerhead/templatefunctions.py'
169--- loggerhead/templatefunctions.py 2018-10-20 16:06:44 +0000
170+++ loggerhead/templatefunctions.py 2020-07-08 17:24:49 +0000
171@@ -201,9 +201,6 @@
172
173 # TODO: On old Python versions, elementtree may be used.
174
175- import simplejson
176- versions.append(('simplejson', simplejson.__version__))
177-
178 try:
179 Dozer = pkg_resources.get_distribution('Dozer')
180 except pkg_resources.DistributionNotFound:
181
182=== modified file 'loggerhead/tests/test_simple.py'
183--- loggerhead/tests/test_simple.py 2020-05-06 19:06:44 +0000
184+++ loggerhead/tests/test_simple.py 2020-07-08 17:24:49 +0000
185@@ -21,9 +21,9 @@
186 from html import escape
187 except ImportError:
188 from cgi import escape
189+import json
190 import logging
191 import re
192-import simplejson
193 from io import BytesIO
194
195 from breezy.tests import TestCaseWithTransport
196@@ -62,7 +62,7 @@
197 self.assertEqual('200 OK', start[0])
198 self.assertEqual('application/json', dict(start[1])['Content-Type'])
199 self.assertEqual(None, start[2])
200- simplejson.loads(content)
201+ json.loads(content.decode('UTF-8'))
202
203 def make_branch_app(self, branch, **kw):
204 branch_app = BranchWSGIApp(branch, friendly_name='friendly-name', **kw)
205
206=== modified file 'loggerhead/util.py'
207--- loggerhead/util.py 2020-05-06 19:18:04 +0000
208+++ loggerhead/util.py 2020-07-08 17:24:49 +0000
209@@ -670,6 +670,8 @@
210 d = obj.__dict__.copy()
211 del d['_properties']
212 return d
213+ elif isinstance(obj, bytes):
214+ return obj.decode('UTF-8')
215 elif isinstance(obj, datetime.datetime):
216 return tuple(obj.utctimetuple())
217 raise TypeError(repr(obj) + " is not JSON serializable")
218
219=== modified file 'setup.py'
220--- setup.py 2020-06-08 10:03:32 +0000
221+++ setup.py 2020-07-08 17:24:49 +0000
222@@ -56,6 +56,6 @@
223 'loggerheadd',
224 'breezy.conf']),
225 ],
226- install_requires=['simplejson', 'paste', 'bleach'],
227+ install_requires=['paste', 'bleach'],
228 testsuite='loggerhead.tests.test_suite',
229 )

Subscribers

People subscribed via source and target branches