New submission from David MacIver <david.maci...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue31958>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to