summaryrefslogtreecommitdiffstats
path: root/Lib/uuid.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-98415: Fix uuid.getnode() ifconfig implementation (GH-98423)Miss Islington (bot)2022-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(). (cherry picked from commit e3ec272f57c3948834a6159cf2604978d3db67a0) Co-authored-by: Chaim Sanders <csanders-git@users.noreply.github.com> Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
* [3.10] bpo-44559: [Enum] revert enum module to 3.9 (GH-27010)Ethan Furman2021-07-041-3/+2
| | | * [Enum] revert enum module to 3.9
* 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.
| * Issue #17293: uuid.getnode() now determines MAC address on AIX using netstat.Serhiy Storchaka2014-11-071-19/+50
| | | | | | | | Based on patch by Aivars Kalvāns.
| * Issue #22131: Fixed a bug in handling an error occured during reading fromSerhiy Storchaka2014-09-061-3/+1
| | | | | | | | a pipe in _ipconfig_getnode().
* | Issue #22793, #22637: Add missing "import os" in uuid._ifconfig_getnode()Victor Stinner2014-11-051-0/+1
| |
* | Issue #22637: avoid using a shell in uuidVictor Stinner2014-10-211-12/+20
| | | | | | | | Replace os.popen() with subprocess.Popen() in the uuid module.
* | Issue #22131: Modernized the code of the uuid module.Serhiy Storchaka2014-09-061-21/+12
| | | | | | | | | | | | | | | | Optimized bytes and bytes_le properties of UUID and UUID constructor with bytes_le argument. Fixed a bug in handling an error occured during reading from a pipe in _ipconfig_getnode().
* | Issue #22033: Reprs of most Python implemened classes now contain actualSerhiy Storchaka2014-07-251-1/+1
|/ | | | class name instead of hardcoded one.
* Merge #19855: restore use of LC_ALL, not LC_MESSAGESR David Murray2014-01-181-3/+4
|\
| * #19855: restore use of LC_ALL, not LC_MESSAGESR David Murray2014-01-181-2/+2
| | | | | | | | | | | | I didn't realize LC_ALL was an override, and I should have. I tried to make a test, but it is not clear that the LC variables actually affect the strings that uuid is using to parse the command output.
* | Merge: #19855: uuid.get_node now looks on the PATH for executables on unix.R David Murray2013-12-181-27/+28
|\ \ | |/