Skip to content

AssertionError in test_uuid on NetBSD: Expected UUID version 1, but got version 4 #124228

Closed

Description

@furkanonder

Bug report

Bug description:

home# ./python -m test test_uuid
Using random seed: 2311813199
0:00:00 load avg: 0.11 Run 1 test sequentially in a single process
0:00:00 load avg: 0.11 [1/1] test_uuid
test test_uuid failed -- Traceback (most recent call last):
  File "/home/blue/cpython/Lib/test/test_uuid.py", line 496, in test_uuid1
    equal(u.version, 1)
    ~~~~~^^^^^^^^^^^^^^
AssertionError: 4 != 1

test_uuid failed (1 failure)

== Tests result: FAILURE ==

1 test failed:
    test_uuid

Total duration: 1.1 sec
Total tests: run=72 failures=1 skipped=13
Total test files: run=1/1 failed=1
Result: FAILURE

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    testsTests in the Lib/test dir
    3.12only security fixes
    3.13only security fixes
    3.14bugs and security fixes
    on Sep 18, 2024
  2. furkanonder commented on Sep 18, 2024

    @furkanonder
    ContributorAuthor

    In NetBSD the py_uuid_generate_time_safe function generates a uuid using the uuid_create and uuid_enc_be functions. The uuid version generated is 4.

    An example to reproduce the situation;

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <uuid.h>
    
    int main() {
        uuid_t *uuid;
        unsigned char encoded_uuid[16];
    
        uuid = malloc(sizeof(struct uuid));
        if (!uuid) {
            fprintf(stderr, "Memory allocation failed\n");
            return 1;
        }
    
        uuid_create(uuid, NULL);
        uuid_enc_be(encoded_uuid, uuid);
    
        printf("Converted UUID: ");
        for (int i = 0; i < 16; i++) {
            printf("%02x", encoded_uuid[i]);
            if ((i == 3 || i == 5 || i == 7 || i == 9) && i < 15) {
                printf("-");
            }
        }
    
        printf("\n");
        free(uuid);
    
        return 0;
    }
    home$ gcc uuid_example.c -o uuid_example
    home$ ./uuid_example
    Converted UUID: 18bea948-0a56-4b61-9973-10ce1a098203
    home$ ./uuid_example
    Converted UUID: 1b2f696c-942e-490d-bfa6-d49246de6ad2
    home$ ./uuid_example
    Converted UUID: f9aa5345-9ac2-4528-8817-bf5b8a60ba4d
  3. added a commit that references this issue on Sep 23, 2024
  4. vstinner commented on Sep 23, 2024

    @vstinner
    Member

    Fixed by 2e8c769.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13only security fixes3.14bugs and security fixesOS-netbsdtestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions