aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/json/__init__.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-02-20 19:54:16 +0100
committerGeorg Brandl <georg@python.org>2012-02-20 19:54:16 +0100
commit2daf6ae2495c862adf8bc717bfe9964081ea0b10 (patch)
treeebd7efe668e4f7842c6d51bdbde47b00f92a57db /Lib/json/__init__.py
parentec1712a1662282c909b4cd4cc0c7486646bc9246 (diff)
downloadcpython-2daf6ae2495c862adf8bc717bfe9964081ea0b10.tar.gz
cpython-2daf6ae2495c862adf8bc717bfe9964081ea0b10.zip
Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
in order to make algorithmic complexity attacks on (e.g.) web apps much more complicated. The environment variable PYTHONHASHSEED and the new command line flag -R control this behavior.
Diffstat (limited to 'Lib/json/__init__.py')
-rw-r--r--Lib/json/__init__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py
index 6d88931dcbd..ba2bc1d3426 100644
--- a/Lib/json/__init__.py
+++ b/Lib/json/__init__.py
@@ -31,7 +31,9 @@ Encoding basic Python object hierarchies::
Compact encoding::
>>> import json
- >>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',', ':'))
+ >>> from collections import OrderedDict
+ >>> mydict = OrderedDict([('4', 5), ('6', 7)])
+ >>> json.dumps([1,2,3,mydict], separators=(',', ':'))
'[1,2,3,{"4":5,"6":7}]'
Pretty printing::