Version number more than 5 returned for UUID #322

Closed
opened 2018-09-20 02:02:31 -05:00 by tirkarthi · 3 comments
tirkarthi commented 2018-09-20 02:02:31 -05:00 (Migrated from github.com)

Describe the bug

The version for UUID "481a8de5-f0d1-f211-b425-e41f134196da" seems to return 15 while 1 to 5 are the valid versions. This is reported as a bug in CPython https://bugs.python.org/issue34732 . I tried with Java 9 and this library that seem to produce same output.

To Reproduce
Steps to reproduce the behavior:


// src/main.rs

extern crate uuid;
use uuid::Uuid;

fn main() {
    let my_uuid = Uuid::parse_str("481a8de5-f0d1-f211-b425-e41f134196da").unwrap();
    println!("Parsed a version {} UUID.", my_uuid.get_version_num());
    println!("{}", my_uuid);
}

output

Parsed a version 15 UUID.
481a8de5-f0d1-f211-b425-e41f134196da

Expected behavior

Is there any validation done for the version number?

Specifications:

Other

https://bugs.python.org/issue34732

Thanks

**Describe the bug** The version for UUID "481a8de5-f0d1-f211-b425-e41f134196da" seems to return 15 while 1 to 5 are the valid versions. This is reported as a bug in CPython https://bugs.python.org/issue34732 . I tried with Java 9 and this library that seem to produce same output. **To Reproduce** Steps to reproduce the behavior: ```rust // src/main.rs extern crate uuid; use uuid::Uuid; fn main() { let my_uuid = Uuid::parse_str("481a8de5-f0d1-f211-b425-e41f134196da").unwrap(); println!("Parsed a version {} UUID.", my_uuid.get_version_num()); println!("{}", my_uuid); } ``` **output** ``` Parsed a version 15 UUID. 481a8de5-f0d1-f211-b425-e41f134196da ``` **Expected behavior** Is there any validation done for the version number? **Specifications:** - RFC section : https://tools.ietf.org/html/rfc4122#section-4.1.3 **Other** https://bugs.python.org/issue34732 Thanks
KodrAus commented 2018-09-20 07:50:39 -05:00 (Migrated from github.com)

Hi @tirkarthi! There is an alternative get_version method that will only return an RFC 4122 specified version (with the addition of a Nil version).

Hi @tirkarthi! There is an alternative [`get_version`](https://docs.rs/uuid/0.7.1/uuid/struct.Uuid.html#method.get_version) method that will only return an RFC 4122 specified version (with the addition of a `Nil` version).
tirkarthi commented 2018-09-20 08:13:12 -05:00 (Migrated from github.com)

Thanks, it works as expected. Closing it.

Thanks, it works as expected. Closing it.
kinggoesgaming commented 2018-09-20 17:52:02 -05:00 (Migrated from github.com)

I think the documentation should be improved to make sure people dont mess this up.

Edit:

The documentation seems to be all over the place for these two methods, so an update to the docs is definitely needed!

I think the documentation should be improved to make sure people dont mess this up. Edit: The documentation seems to be all over the place for these two methods, so an update to the docs is definitely needed!
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-uuid-rs/uuid#322
No description provided.