@@ -21,7 +21,7 @@ Command line
21
21
22
22
When invoking Python, you may specify any of these options::
23
23
24
-
python [-bBdEhiOsSuvVWx?] [-c command | -m module-name | script | - ] [args]
24
+
python [-bBdEhiORsSuvVWx?] [-c command | -m module-name | script | - ] [args]
25
25
26
26
The most common use case is, of course, a simple invocation of a script::
27
27
@@ -215,6 +215,29 @@ Miscellaneous options
215
215
Discard docstrings in addition to the :option:`-O` optimizations.
216
216
217
217
218
+
.. cmdoption:: -R
219
+
220
+
Turn on hash randomization, so that the :meth:`__hash__` values of str, bytes
221
+
and datetime objects are "salted" with an unpredictable random value.
222
+
Although they remain constant within an individual Python process, they are
223
+
not predictable between repeated invocations of Python.
224
+
225
+
This is intended to provide protection against a denial-of-service caused by
226
+
carefully-chosen inputs that exploit the worst case performance of a dict
227
+
insertion, O(n^2) complexity. See
228
+
http://www.ocert.org/advisories/ocert-2011-003.html for details.
229
+
230
+
Changing hash values affects the order in which keys are retrieved from a
231
+
dict. Although Python has never made guarantees about this ordering (and it
232
+
typically varies between 32-bit and 64-bit builds), enough real-world code
233
+
implicitly relies on this non-guaranteed behavior that the randomization is
234
+
disabled by default.
235
+
236
+
See also :envvar:`PYTHONHASHSEED`.
237
+
238
+
.. versionadded:: 3.1.5
239
+
240
+
218
241
.. cmdoption:: -s
219
242
220
243
Don't add user site directory to sys.path
@@ -314,6 +337,7 @@ Miscellaneous options
314
337
315
338
.. note:: The line numbers in error messages will be off by one.
316
339
340
+
317
341
Options you shouldn't use
318
342
~~~~~~~~~~~~~~~~~~~~~~~~~
319
343
@@ -328,6 +352,7 @@ Options you shouldn't use
328
352
Reserved for alternative implementations of Python to use for their own
329
353
purposes.
330
354
355
+
331
356
.. _using-on-envvars:
332
357
333
358
Environment variables
@@ -435,6 +460,27 @@ These environment variables influence Python's behavior.
435
460
import of source modules.
436
461
437
462
463
+
.. envvar:: PYTHONHASHSEED
464
+
465
+
If this variable is set to ``random``, the effect is the same as specifying
466
+
the :option:`-R` option: a random value is used to seed the hashes of str,
467
+
bytes and datetime objects.
468
+
469
+
If :envvar:`PYTHONHASHSEED` is set to an integer value, it is used as a fixed
470
+
seed for generating the hash() of the types covered by the hash
471
+
randomization.
472
+
473
+
Its purpose is to allow repeatable hashing, such as for selftests for the
474
+
interpreter itself, or to allow a cluster of python processes to share hash
475
+
values.
476
+
477
+
The integer must be a decimal number in the range [0,4294967295]. Specifying
478
+
the value 0 will lead to the same hash values as when hash randomization is
479
+
disabled.
480
+
481
+
.. versionadded:: 3.1.5
482
+
483
+
438
484
.. envvar:: PYTHONIOENCODING
439
485
440
486
Overrides the encoding used for stdin/stdout/stderr, in the syntax
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4