http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11311
Revision: 11311 Author: legoktm Date: 2013-03-31 17:05:13 +0000 (Sun, 31 Mar 2013) Log Message: ----------- Use json.dumps so that special characters are encoded properly.
Modified Paths: -------------- branches/rewrite/pywikibot/site.py
Modified: branches/rewrite/pywikibot/site.py =================================================================== --- branches/rewrite/pywikibot/site.py 2013-03-31 17:04:00 UTC (rev 11310) +++ branches/rewrite/pywikibot/site.py 2013-03-31 17:05:13 UTC (rev 11311) @@ -3376,9 +3376,9 @@ params['value'] = json.dumps({'entity-type': 'item', 'numeric-id': claim.getTarget().getID(numeric=True)}) elif claim.getType() == 'string': - params['value'] = '"' + claim.getTarget() + '"' + params['value'] = json.dumps(claim.getTarget()) elif claim.getType() == 'commonsMedia': - params['value'] = '"' + claim.getTarget().title(withNamespace=False) + '"' + params['value'] = json.dumps(claim.getTarget().title(withNamespace=False)) else: raise NotImplementedError('%s datatype is not supported yet.' % claim.getType()) params['token'] = self.token(item, 'edit') @@ -3413,9 +3413,9 @@ params['value'] = json.dumps({'entity-type': 'item', 'numeric-id': claim.getTarget().getID(numeric=True)}) elif claim.getType() == 'string': - params['value'] = '"' + claim.getTarget() + '"' + params['value'] = json.dumps(claim.getTarget()) elif claim.getType() == 'commonsMedia': - params['value'] = '"' + claim.getTarget().title(withNamespace=False) + '"' + params['value'] = json.dumps(claim.getTarget().title(withNamespace=False)) else: raise NotImplementedError('%s datatype is not supported yet.' % claim.getType())
pywikipedia-svn@lists.wikimedia.org