summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-12-01 05:45:10 +0000
committerNick Mathewson <nickm@torproject.org>2008-12-01 05:45:10 +0000
commit75b8e715e9888522c89f0b9136278e6398251c72 (patch)
treefb1336de7070b65d82c23aa224896e741b924e5b /lib
parent4ebc57ff2a32f7dcaa765995e928b5def6a5cee3 (diff)
Kludge harder.
git-svn-id: file:///home/or/svnrepo/updater/trunk@17423 55e972cd-5a19-0410-ae62-a4d7a52db4cd
Diffstat (limited to 'lib')
-rw-r--r--lib/thandy/util.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/thandy/util.py b/lib/thandy/util.py
index e01600e..61478ac 100644
--- a/lib/thandy/util.py
+++ b/lib/thandy/util.py
@@ -42,6 +42,9 @@ def importJSON():
# code is not guaranteed to work on all broken versions of simplejson:
# it replaces an entry in the internal character-replacement
# dictionary so that "/" is translated to itself rather than to \/.
+ # We also need to make sure that ensure_ascii is False, so that we
+ # do not call the C-optimized string encoder in these broken versions,
+ # which we can't fix easily. Both parts are a kludge.
try:
escape_dct = mod.encoder.ESCAPE_DCT
except NameError:
@@ -49,6 +52,16 @@ def importJSON():
else:
if escape_dct.has_key("/"):
escape_dct["/"] = "/"
+ save_dumps = simplejson.dumps
+ save_dump = simplejson.dump
+ def dumps(*k, **v):
+ v['ensure_ascii']=False
+ return save_dumps(*k,**v)
+ def dump(*k,**v):
+ v['ensure_ascii']=False
+ return save_dump(*k,**v)
+ simplejson.dump = dump
+ simplejson.dumps = dumps
logging.warn("Your operating system has an old broken "
"simplejson module. I tried to fix it for you.")