summaryrefslogtreecommitdiffstats
path: root/Lib/uuid.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-113308: Remove some internal parts of `uuid` module (#115934)Nikita Sobolev2024-03-141-16/+0
| | | Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* gh-71052: Change Android's `sys.platform` from "linux" to "android"Malcolm Smith2024-03-111-1/+1
| | | | Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-109653: Reduce import overhead of uuid module on Linux (#115160)Shantanu2024-03-061-1/+4
| | | | | | | | | | | | | | | | | | | 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 ```
* gh-104396: uuid.py to skip platform check for emscripten and wasi (gh-104397)Jeong, YunWon2023-05-111-1/+1
|
* Update MAC_address wikipedia URL in comments (#29019)1809092023-04-261-2/+2
|
* gh-94684: uuid: support bytes in the name argument to uuid3/5 (#94709)MonadChains2023-03-231-2/+6
| | | 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.
* GH-88597: Rename uuid's new CLI args to be in line with uuidgen. (#101248)achhina2023-01-251-12/+16
| | | this way they match an existing uuidgen command line tool.
* GH-88597: Added command line interface to UUID module. (#99463)achhina2023-01-221-0/+49
| | | | | | | | | | | | 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] ... ```
* gh-98415: Fix uuid.getnode() ifconfig implementation (#98423)Chaim Sanders2022-11-021-2/+7
| | | | | | | | | 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>
* gh-95174: Handle missing waitpid and gethostbyname in WASI (GH-95181)Christian Heimes2022-07-241-0/+2
|
* bpo-45155: Apply new byteorder default values for int.to/from_bytes (GH-28465)Raymond Hettinger2021-09-201-2/+2
|
* bpo-38659: [Enum] add _simple_enum decorator (GH-25497)Ethan Furman2021-04-211-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "bpo-38659: [Enum] add _simple_enum decorator (GH-25285)" (GH-25476)Ethan Furman2021-04-201-3/+2
| | | This reverts commit dbac8f40e81eb0a29dc833e6409a1abf47467da6.
* bpo-38659: [Enum] add _simple_enum decorator (GH-25285)Ethan Furman2021-04-201-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* bpo-41364: Reduce import overhead of uuid module (GH-21586)Steve Dower2020-07-211-7/+9
|
* bpo-40501: Replace ctypes code in uuid with native module (GH-19948)Steve Dower2020-05-121-157/+23
|
* bpo-39991: Enhance uuid parser for MAC address (GH-19045)Victor Stinner2020-03-171-31/+41
| | | | Reject valid IPv6 addresses which doesn't contain "::" but have a length of 17 characters.
* bpo-39991: uuid._netstat_getnode() ignores IPv6 addresses (GH-19043)Victor Stinner2020-03-171-1/+4
| | | | uuid.getnode() now skips IPv6 addresses with the same string length than a MAC address (17 characters): only use MAC addresses.
* bpo-39559: Remove unused, undocumented argument from uuid.getnode (GH-18369)Shantanu2020-02-051-1/+1
|
* bpo-28009: Fix uuid.uuid1() and uuid.get_node() on AIX (GH-8672)Michael Felt2019-09-261-72/+123
|
* bpo-9216: Add usedforsecurity to hashlib constructors (GH-16044)Christian Heimes2019-09-131-2/+5
| | | | | 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
* Fix typos mostly in comments, docs and test names (GH-15209)Min ho Kim2019-08-301-1/+1
|
* bpo-28009: Fix uuid SkipUnless logic to be based on platform programs ↵Michael Felt2019-06-151-11/+32
| | | | | | | | | | | | | 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).
* bpo-35701: Added __weakref__ slot to uuid.UUID (GH-11570)David H2019-01-171-1/+1
| | | Added test for weakreferencing a uuid.UUID object.
* bpo-31784: Use time.time_ns() in uuid.uuid1() (GH-11189)Victor Stinner2018-12-181-2/+2
| | | | | 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.
* bpo-30977: rework code changes according to post-merge code review (GH-9106)Tal Einat2018-09-101-17/+10
| | | | also mention the change and its consequences in What's New
* bpo-30977: make uuid.UUID use __slots__ (GH-9078)Tal Einat2018-09-061-2/+26
| | | Co-Authored-By: Wouter Bolsterlee.
* bpo-33542: Ignore DUID in uuid.get_node on Windows. (GH-6922)CtrlZvi2018-05-201-1/+1
| | | | | | 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.
* bpo-32370: Use the correct encoding for ipconfig output in the uuid module. ↵Segev Finer2018-02-131-4/+6
| | | | (GH-5608)
* bpo-32502: Discard 64-bit (and other invalid) hardware addresses (#5254)Bo Bayles2018-01-241-6/+10
|
* bpo-32199: The getnode() ip getter now uses 'ip link' instead of 'ip link ↵xdegaye2017-12-071-1/+1
| | | | list' (GH-4696)
* Fix a regression in uuid added in bpo-32107. (#4677)Serhiy Storchaka2017-12-041-2/+2
| | | | | 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.
* bpo-32107 - Improve MAC address calculation and fix test_uuid.py (#4600)Barry Warsaw2017-11-281-11/+60
| | | | | | | | ``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.
* Revert "bpo-32107 - Better merge of #4494 (#4576)" (#4593)Victor Stinner2017-11-271-59/+11
| | | This reverts commit 9522a218f7dff95c490ff359cc60e8c2af35f5c8.
* bpo-32107 - Better merge of #4494 (#4576)Barry Warsaw2017-11-271-11/+59
| | | | | | | | | | | | | | | | 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.
* bpo-9678: Fix determining the MAC address in the uuid module. (#4264)Serhiy Storchaka2017-11-041-2/+16
| | | | | | * Using ifconfig on NetBSD and OpenBSD. * Using arp on Linux, FreeBSD, NetBSD and OpenBSD. Based on patch by Takayuki Shimizukawa.
* bpo-11063: Fix _uuid module on macOS (#3855)Victor Stinner2017-10-021-1/+1
| | | | | 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 (#3796)Antoine Pitrou2017-09-281-68/+108
| | | | bpo-11063, bpo-20519: avoid ctypes and improve import time for uuid.
* remove IRIX support (closes bpo-31341) (#3310)Benjamin Peterson2017-09-041-1/+1
| | | See PEP 11.
* bpo-22807: Expose platform UUID generation safety information. (#138)Barry Warsaw2017-02-181-6/+37
| | | | bpo-22807: Expose platform UUID generation safety information.
* Removed unused imports.Serhiy Storchaka2016-04-241-1/+0
|
* Issue #19164: Improve exception message of uuid.UUID()Berker Peksag2016-03-201-1/+2
| | | | Patch by jgauthier.
* always use os.urandom for the uuid4 algorithm (closes #25515)Benjamin Peterson2015-10-301-20/+6
|
* Issue #24634: Importing uuid should not try to load libc on WindowsSteve Dower2015-07-141-2/+6
|
* Issue #16261: Converted some bare except statements to except statementsSerhiy Storchaka2015-05-201-2/+2
| | | | with specified exception type. Original patch by Ramchandra Apte.
* Issue #23326: Removed __ne__ implementations. Since fixing default __ne__Serhiy Storchaka2015-01-311-5/+0
| | | | implementation in issue #21408 they are redundant.
* Issue #22902: The "ip" command is now used on Linux to determine MAC addressSerhiy Storchaka2014-11-301-2/+9
| | | | in uuid.getnode(). Pach by Bruno Cauet.
* Issue #19720: Suppressed context for some exceptions in importlib.Serhiy Storchaka2014-11-211-1/+4
|\
| * Issue #17293: socket.gethostbyname() can raise an exception of FreeBSD.Serhiy Storchaka2014-11-211-1/+4
| |
* | Issue #17293: uuid.getnode() now determines MAC address on AIX using netstat.Serhiy Storchaka2014-11-071-28/+55
|\ \ | |/ | | | | Based on patch by Aivars Kalvāns.