| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
| |
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
|
|
|
|
| |
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This follows in the footsteps of #21586
This speeds up import uuid by about 6ms on Linux.
Before:
```
λ hyperfine -w 4 "./python -c 'import uuid'"
Benchmark 1: ./python -c 'import uuid'
Time (mean ± σ): 20.4 ms ± 0.4 ms [User: 16.7 ms, System: 3.8 ms]
Range (min … max): 19.6 ms … 21.8 ms 136 runs
```
After:
```
λ hyperfine -w 4 "./python -c 'import uuid'"
Benchmark 1: ./python -c 'import uuid'
Time (mean ± σ): 14.5 ms ± 0.3 ms [User: 11.5 ms, System: 3.2 ms]
Range (min … max): 13.9 ms … 16.0 ms 175 runs
```
|
| |
|
| |
|
|
|
| |
RFC 4122 does not specify that name should be a string, so for completness the functions should also support a name given as a raw byte sequence.
|
|
|
| |
this way they match an existing uuidgen command line tool.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The `uuid` module now supports command line usage.
```python
❯ ./python.exe -m uuid
5f2d57b1-90e8-417c-ba5d-69b9b6f74289
❯ ./python.exe -m uuid -h
usage: uuid.py [-h] [-u {uuid1,uuid3,uuid4,uuid5}] [-ns NAMESPACE] [-n NAME]
...
```
|
|
|
|
|
|
|
|
|
| |
The uuid.getnode() function has multiple implementations, tested sequentially.
The ifconfig implementation was incorrect and always failed: fix it.
In practice, functions of libuuid library are preferred, if available:
uuid_generate_time_safe(), uuid_create() or uuid_generate_time().
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
add:
* `_simple_enum` decorator to transform a normal class into an enum
* `_test_simple_enum` function to compare
* `_old_convert_` to enable checking `_convert_` generated enums
`_simple_enum` takes a normal class and converts it into an enum:
@simple_enum(Enum)
class Color:
RED = 1
GREEN = 2
BLUE = 3
`_old_convert_` works much like` _convert_` does, using the original logic:
# in a test file
import socket, enum
CheckedAddressFamily = enum._old_convert_(
enum.IntEnum, 'AddressFamily', 'socket',
lambda C: C.isupper() and C.startswith('AF_'),
source=_socket,
)
`_test_simple_enum` takes a traditional enum and a simple enum and
compares the two:
# in the REPL or the same module as Color
class CheckedColor(Enum):
RED = 1
GREEN = 2
BLUE = 3
_test_simple_enum(CheckedColor, Color)
_test_simple_enum(CheckedAddressFamily, socket.AddressFamily)
Any important differences will raise a TypeError
|
|
|
| |
This reverts commit dbac8f40e81eb0a29dc833e6409a1abf47467da6.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
add:
_simple_enum decorator to transform a normal class into an enum
_test_simple_enum function to compare
_old_convert_ to enable checking _convert_ generated enums
_simple_enum takes a normal class and converts it into an enum:
@simple_enum(Enum)
class Color:
RED = 1
GREEN = 2
BLUE = 3
_old_convert_ works much like _convert_ does, using the original logic:
# in a test file
import socket, enum
CheckedAddressFamily = enum._old_convert_(
enum.IntEnum, 'AddressFamily', 'socket',
lambda C: C.isupper() and C.startswith('AF_'),
source=_socket,
)
test_simple_enum takes a traditional enum and a simple enum and
compares the two:
# in the REPL or the same module as Color
class CheckedColor(Enum):
RED = 1
GREEN = 2
BLUE = 3
_test_simple_enum(CheckedColor, Color)
_test_simple_enum(CheckedAddressFamily, socket.AddressFamily)
Any important differences will raise a TypeError
|
| |
|
| |
|
|
|
|
| |
Reject valid IPv6 addresses which doesn't contain "::" but have
a length of 17 characters.
|
|
|
|
| |
uuid.getnode() now skips IPv6 addresses with the same string length
than a MAC address (17 characters): only use MAC addresses.
|
| |
|
| |
|
|
|
|
|
| |
The usedforsecurity keyword only argument added to the hash constructors is useful for FIPS builds and similar restrictive environment with non-technical requirements that legacy algorithms be forbidden by their implementations without being explicitly annotated as not being used for any security related purposes. Linux distros with FIPS support benefit from this being standard rather than making up their own way(s) to do it.
Contributed and Signed-off-by: Christian Heimes christian@python.org
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
capable of introspection (GH-12777)
uuid could try fallback methods that had no chance of working on a particular
platform, and this could cause spurious test failures, as well as degraded
performance as fallback options were tried and failed.
This fixes both the uuid module and its test's SkipUnless logic to use a
prefiltered list of techniques that may at least potentially work on that platform.
Patch by Michael Felt (aixtools).
|
|
|
| |
Added test for weakreferencing a uuid.UUID object.
|
|
|
|
|
| |
uuid.uuid1() now calls time.time_ns() rather than
int(time.time() * 1e9). Replace also int(nanoseconds/100)
with nanoseconds // 100. Add an unit test.
|
|
|
|
| |
also mention the change and its consequences in What's New
|
|
|
| |
Co-Authored-By: Wouter Bolsterlee.
|
|
|
|
|
|
| |
uuid._ipconfig_getnode did not validate the maximum length of the value,
so long as the value had the same type of formatting as a MAC address.
This let it select DUIDs as MAC addresses. It now requires an exact
length match.
|
|
|
|
| |
(GH-5608)
|
| |
|
|
|
|
| |
list' (GH-4696)
|
|
|
|
|
| |
uuid.get_node() always must return a stable result.
Also added a test for non-reproducibility of _random_getnode().
Original patch by Xavier de Gaye.
|
|
|
|
|
|
|
|
| |
``uuid.getnode()`` now preferentially returns universally administered MAC addresses if available, over locally administered MAC addresses. This makes a better guarantee for global uniqueness of UUIDs returned from ``uuid.uuid1()``. If only locally administered MAC addresses are available, the first such one found is returned.
Also improve internal code style by being explicit about ``return None`` rather than falling off the end of the function.
Improve the test robustness.
|
|
|
| |
This reverts commit 9522a218f7dff95c490ff359cc60e8c2af35f5c8.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Improve UUID1 MAC address calculation and related tests.
There are two bits in the MAC address that are relevant to UUID1. The first is the locally administered vs. universally administered bit (second least significant of the first octet). Physical network interfaces such as ethernet ports and wireless adapters will always be universally administered, but some interfaces --such as the interface that MacBook Pros communicate with their Touch Bars-- are locally administered. The former are guaranteed to be globally unique, while the latter are demonstrably *not* globally unique and are in fact the same on every MBP with a Touch Bar. With this bit is set, the MAC is locally administered; with it unset it is universally administered.
The other bit is the multicast bit (least significant bit of the first octet). When no other MAC address can be found, RFC 4122 mandates that a random 48-bit number be generated. This randomly generated number *must* have the multicast bit set.
The improvements in uuid.py include:
* Preferentially return a universally administered MAC address, falling back to a locally administered address if none of the former can be found.
* Improve several coding style issues, such as adding explicit returns of None, using a more readable bitmask pattern, and assuming that the ultimate fallback, random MAC generation will not fail (and propagating any exception there instead of swallowing them).
Improvements in test_uuid.py include:
* Always testing the calculated MAC for universal administration, unless explicitly disabled (i.e. for the random case), or implicitly disabled due to running in the Travis environment. Travis test machines have *no* universally administered MAC address at the time of this writing.
|
|
|
|
|
|
| |
* Using ifconfig on NetBSD and OpenBSD.
* Using arp on Linux, FreeBSD, NetBSD and OpenBSD.
Based on patch by Takayuki Shimizukawa.
|
|
|
|
|
| |
On macOS, use uuid_generate_time() instead of
uuid_generate_time_safe() of libuuid, since uuid_generate_time_safe()
is not available.
|
|
|
|
| |
bpo-11063, bpo-20519: avoid ctypes and improve import time for uuid.
|
|
|
| |
See PEP 11.
|
|
|
|
| |
bpo-22807: Expose platform UUID generation safety information.
|
| |
|
|
|
|
| |
Patch by jgauthier.
|
| |
|
| |
|
|
|
|
| |
with specified exception type. Original patch by Ramchandra Apte.
|
|
|
|
| |
implementation in issue #21408 they are redundant.
|
|
|
|
| |
in uuid.getnode(). Pach by Bruno Cauet.
|
|\ |
|
| | |
|
|\ \
| |/
| |
| | |
Based on patch by Aivars Kalvāns.
|