← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py36-fix-apportjob into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py36-fix-apportjob into launchpad:master.

Commit message:
Fix json.dumps call for Python >= 3.6

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/432593

The `json.dumps` call in `lp.bugs.model.apportjob` started failing on Python >= 3.6 after the change to drop the dependency on `simplejson`, because `json.dumps` changed in 3.6 to make most arguments keyword-only.  Passing the encoding as a positional argument has probably been incorrect for a long time since the encoding wasn't the next argument after the object to dump, but this hasn't mattered since Python 3 anyway.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py36-fix-apportjob into launchpad:master.
diff --git a/lib/lp/bugs/model/apportjob.py b/lib/lp/bugs/model/apportjob.py
index a4612d5..05007dc 100644
--- a/lib/lp/bugs/model/apportjob.py
+++ b/lib/lp/bugs/model/apportjob.py
@@ -60,7 +60,7 @@ class ApportJob(StormBase):
     # only delegates to ApportJob we can't simply directly access the
     # _json_data property, so we use a getter and setter here instead.
     def _set_metadata(self, metadata):
-        self._json_data = six.ensure_text(json.dumps(metadata, "utf-8"))
+        self._json_data = six.ensure_text(json.dumps(metadata))
 
     def _get_metadata(self):
         return json.loads(self._json_data)