| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1018,7 +1018,7 @@ operations have the same priority as the corresponding numeric operations. [3]_ | |||
| 1018 | 1018 | | ``s * n`` or | equivalent to adding *s* to | (2)(7) | | |
| 1019 | 1019 | | ``n * s`` | itself *n* times | | | |
| 1020 | 1020 | +--------------------------+--------------------------------+----------+ | |
| 1021 | - | ``s[i]`` | *i*\ th item of *s*, origin 0 | \(3) | | ||
| 1021 | + | ``s[i]`` | *i*\ th item of *s*, origin 0 | (3)(9) | | ||
| 1022 | 1022 | +--------------------------+--------------------------------+----------+ | |
| 1023 | 1023 | | ``s[i:j]`` | slice of *s* from *i* to *j* | (3)(4) | | |
| 1024 | 1024 | +--------------------------+--------------------------------+----------+ | |
@@ -1150,6 +1150,9 @@ Notes: | |||
| 1150 | 1150 | without copying any data and with the returned index being relative to | |
| 1151 | 1151 | the start of the sequence rather than the start of the slice. | |
| 1152 | 1152 | ||
| 1153 | + (9) | ||
| 1154 | + An :exc:`IndexError` is raised if *i* is outside the sequence range. | ||
| 1155 | + | ||
| 1153 | 1156 | ||
| 1154 | 1157 | .. _typesseq-immutable: | |
| 1155 | 1158 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -257,6 +257,10 @@ The :mod:`uuid` module defines the following functions: | |||
| 257 | 257 | non-specified arguments are substituted for a pseudo-random integer of | |
| 258 | 258 | appropriate size. | |
| 259 | 259 | ||
| 260 | + By default, *a*, *b* and *c* are generated by a non-cryptographically | ||
| 261 | + secure pseudo-random number generator (CSPRNG). Use :func:`uuid4` when | ||
| 262 | + a UUID needs to be used in a security-sensitive context. | ||
| 263 | + | ||
| 260 | 264 | .. versionadded:: 3.14 | |
| 261 | 265 | ||
| 262 | 266 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -656,18 +656,20 @@ def _windll_getnode(): | |||
| 656 | 656 | ||
| 657 | 657 | def _random_getnode(): | |
| 658 | 658 | """Get a random node ID.""" | |
| 659 | - # RFC 4122, $4.1.6 says "For systems with no IEEE address, a randomly or | ||
| 660 | - # pseudo-randomly generated value may be used; see Section 4.5. The | ||
| 661 | - # multicast bit must be set in such addresses, in order that they will | ||
| 662 | - # never conflict with addresses obtained from network cards." | ||
| 659 | + # RFC 9562, §6.10-3 says that | ||
| 660 | + # | ||
| 661 | + # Implementations MAY elect to obtain a 48-bit cryptographic-quality | ||
| 662 | + # random number as per Section 6.9 to use as the Node ID. [...] [and] | ||
| 663 | + # implementations MUST set the least significant bit of the first octet | ||
| 664 | + # of the Node ID to 1. This bit is the unicast or multicast bit, which | ||
| 665 | + # will never be set in IEEE 802 addresses obtained from network cards. | ||
| 663 | 666 | # | |
| 664 | 667 | # The "multicast bit" of a MAC address is defined to be "the least | |
| 665 | 668 | # significant bit of the first octet". This works out to be the 41st bit | |
| 666 | 669 | # counting from 1 being the least significant bit, or 1<<40. | |
| 667 | 670 | # | |
| 668 | 671 | # See https://en.wikipedia.org/w/index.php?title=MAC_address&oldid=1128764812#Universal_vs._local_(U/L_bit) | |
| 669 | - import random | ||
| 670 | - return random.getrandbits(48) | (1 << 40) | ||
| 672 | + return int.from_bytes(os.urandom(6)) | (1 << 40) | ||
| 671 | 673 | ||
| 672 | 674 | ||
| 673 | 675 | # _OS_GETTERS, when known, are targeted for a specific OS or platform. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + :mod:`uuid`: when the MAC address cannot be determined, the 48-bit node | ||
| 2 | + ID is now generated with a cryptographically-secure pseudo-random number | ||
| 3 | + generator (CSPRNG) as per :rfc:`RFC 9562, §6.10.3 <9562#section-6.10-3>`. | ||
| 4 | + This affects :func:`~uuid.uuid1` and :func:`~uuid.uuid6`. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -605,7 +605,7 @@ raise_unsupported_digestmod_error(PyObject *module, PyObject *digestmod) | |||
| 605 | 605 | * | |
| 606 | 606 | * Parameters | |
| 607 | 607 | * | |
| 608 | - * digestmod A digest name or a _hashlib.openssl_* function | ||
| 608 | + * digestmod A digest name or a _hashopenssl builtin function | ||
| 609 | 609 | * py_ht The message digest purpose. | |
| 610 | 610 | */ | |
| 611 | 611 | static PY_EVP_MD * | |
| Back | FazBrowse Home | New Git URL |
0 commit comments