Skip to content

UUID wrongly parses hex values with underscores #125651

Description

@sevdog

Bug report

Bug description:

import uuid
uuid.UUID("123_4567812345678123456781234567")
#  UUID('01234567-8123-4567-8123-456781234567')

UUID parsing hex strings internally uses int method which from Python 3.6 accepts underscores (_) as digit separators

Changed in version 3.6: Grouping digits with underscores as in code literals is allowed.

Since the UUID does not performs sanitization of this character this may result in parsing as valid non-RFC compliant UUID values.

CPython versions tested on:

3.10, CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

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

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions