@@ -24,7 +24,7 @@ Command line
2424
2525When invoking Python, you may specify any of these options::
2626
27- python [-bBdEhiOsSuvVWx ?] [-c command | -m module-name | script | - ] [args]
27+ python [-bBdEhiORqsSuvVWx ?] [-c command | -m module-name | script | - ] [args]
2828
2929The most common use case is, of course, a simple invocation of a script::
3030
@@ -227,6 +227,29 @@ Miscellaneous options
227227 .. versionadded :: 3.2
228228
229229
230+ .. cmdoption :: -R
231+
232+ Turn on hash randomization, so that the :meth: `__hash__ ` values of str, bytes
233+ and datetime objects are "salted" with an unpredictable random value.
234+ Although they remain constant within an individual Python process, they are
235+ not predictable between repeated invocations of Python.
236+
237+ This is intended to provide protection against a denial-of-service caused by
238+ carefully-chosen inputs that exploit the worst case performance of a dict
239+ insertion, O(n^2) complexity. See
240+ http://www.ocert.org/advisories/ocert-2011-003.html for details.
241+
242+ Changing hash values affects the order in which keys are retrieved from a
243+ dict. Although Python has never made guarantees about this ordering (and it
244+ typically varies between 32-bit and 64-bit builds), enough real-world code
245+ implicitly relies on this non-guaranteed behavior that the randomization is
246+ disabled by default.
247+
248+ See also :envvar: `PYTHONHASHSEED `.
249+
250+ .. versionadded :: 3.2.3
251+
252+
230253.. cmdoption :: -s
231254
232255 Don't add the :data: `user site-packages directory <site.USER_SITE> ` to
@@ -352,6 +375,7 @@ Options you shouldn't use
352375
353376.. _Jython : http://jython.org
354377
378+
355379.. _using-on-envvars :
356380
357381Environment variables
@@ -460,6 +484,27 @@ These environment variables influence Python's behavior.
460484 option.
461485
462486
487+ .. envvar :: PYTHONHASHSEED
488+
489+ If this variable is set to ``random ``, the effect is the same as specifying
490+ the :option: `-R ` option: a random value is used to seed the hashes of str,
491+ bytes and datetime objects.
492+
493+ If :envvar: `PYTHONHASHSEED ` is set to an integer value, it is used as a fixed
494+ seed for generating the hash() of the types covered by the hash
495+ randomization.
496+
497+ Its purpose is to allow repeatable hashing, such as for selftests for the
498+ interpreter itself, or to allow a cluster of python processes to share hash
499+ values.
500+
501+ The integer must be a decimal number in the range [0,4294967295]. Specifying
502+ the value 0 will lead to the same hash values as when hash randomization is
503+ disabled.
504+
505+ .. versionadded :: 3.2.3
506+
507+
463508.. envvar :: PYTHONIOENCODING
464509
465510 If this is set before running the interpreter, it overrides the encoding used
0 commit comments