[New-bugs-announce] [issue31958] UUID

David MacIver report at bugs.python.org
Mon Nov 6 06:31:27 EST 2017


New submission from David MacIver <david.maciver at gmail.com>:

The documentation for the UUID module says the UUID.version field is "The UUID version number (1 through 5, meaningful only when the variant is RFC_4122)".

However, the UUID constructor doesn't actually validate that the version lies in that range if you don't pass a version to the constructor and, as a result, this isn't actually true - the version number can be anything between 0 and 15.

For an example consider the following:

>>> from uuid import UUID
>>> u = UUID(int=1133377179260751706062848)
>>> u.variant
'specified in RFC 4122'
>>> u.version
15

I have only actually run this example on Python 3.6, but inspection of the code suggests that it's been like this since its introduction.

----------
components: Library (Lib)
messages: 305636
nosy: David MacIver
priority: normal
severity: normal
status: open
title: UUID
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31958>
_______________________________________


More information about the New-bugs-announce mailing list