summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-03-29 08:59:00 +0100
committerRichard van der Hoff <richard@matrix.org>2018-03-29 08:59:00 +0100
commit3309d122f922540102da1463744e1ad54c3ccb18 (patch)
treed887b379d3ba115d7b7c9cad48f134d17e4a6d4f
parentf3ac28677376720c84f60cb74dd9f1ba8fd4f807 (diff)
downloadsimplejson-3309d122f922540102da1463744e1ad54c3ccb18.tar.gz
Remove redundant parts of ESCAPE and ESCAPE_DCT
* `\b\f\n\r\t` are all in the range `\x00-\x1f` so can be omitted from ESCAPE * `ESCAPE_DCT[0x2028:0x2029]` is no longer used in `encode_basestring`, and `py_encode_basestring_ascii` handles them via the generic `\uNNNN` code, so these entries can be removed from `ESCAPE_DCT`.
-rw-r--r--simplejson/encoder.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/simplejson/encoder.py b/simplejson/encoder.py
index 9a78b26..ec73ce3 100644
--- a/simplejson/encoder.py
+++ b/simplejson/encoder.py
@@ -17,7 +17,7 @@ c_encode_basestring_ascii, c_make_encoder = _import_speedups()
from .decoder import PosInf
from .raw_json import RawJSON
-ESCAPE = re.compile(r'[\x00-\x1f\\"\b\f\n\r\t]')
+ESCAPE = re.compile(r'[\x00-\x1f\\"]')
ESCAPE_ASCII = re.compile(r'([\\"]|[^\ -~])')
HAS_UTF8 = re.compile(r'[\x80-\xff]')
ESCAPE_DCT = {
@@ -32,8 +32,6 @@ ESCAPE_DCT = {
for i in range(0x20):
#ESCAPE_DCT.setdefault(chr(i), '\\u{0:04x}'.format(i))
ESCAPE_DCT.setdefault(chr(i), '\\u%04x' % (i,))
-for i in [0x2028, 0x2029]:
- ESCAPE_DCT.setdefault(unichr(i), '\\u%04x' % (i,))
FLOAT_REPR = repr